Skip to content

Instantly share code, notes, and snippets.

@fgerick
Last active July 4, 2019 08:04
Show Gist options
  • Select an option

  • Save fgerick/9bc3272e79c63f77f141d5a2ba6a5dea to your computer and use it in GitHub Desktop.

Select an option

Save fgerick/9bc3272e79c63f77f141d5a2ba6a5dea to your computer and use it in GitHub Desktop.
Shift-invert Arnoldi for targeted generalised eigen problem in Julia
# Solve Ax = λBx using Shift-invert Arnoldi targeting complex σ:
# (A-σB)^-1 Bx = 1/(λ-σ)x
using LinearAlgebra, SparseArrays, Arpack, LinearMaps
n=100
A = sprandn(n,n,0.1)
B = sprandn(n,n,0.1) .+ sparse(1.0I,n,n)
# eigenvalue to target:
σ = 1.0im
P = lu(A-σ*B)
L = LinearMap{ComplexF64}((y,x) -> ldiv!(y,P,B*x),n)
evals,u = eigs(L)
λ = 1.0 ./evals .+ σ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment