Skip to content

Commit

Permalink
faster
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieugomez committed Oct 31, 2023
1 parent 3e8c50c commit 24d05e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/principal_eigenvalue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ In other words, all eigenvalues of 𝕋 have real part <= 0. This means that
"""
function principal_eigenvalue(𝕋; r0 = ones(size(𝕋, 1)))
a, Ξ·, r = 0.0, 0.0, r0
# faster in certain cases. Check that all sum up to zero
try
# faster in certain cases. Check that all sum up to zero
@assert maximum(abs.(sum(𝕋, dims = 1))) < 1e-9
vals, vecs = Arpack.eigs(𝕋; v0 = collect(r0), nev = 1, which = :SM)
# standard way of solving Ax = 0 is to do inverse iteration https://stackoverflow.com/questions/33563401/lapack-routines-for-solving-a-x-0
vals, vecs = Arpack.eigs(𝕋; v0 = collect(r0), nev = 1, which = :LM, sigma = 0.0)
Ξ· = vals[1]
r = vecs[:, 1]
catch
Expand Down

0 comments on commit 24d05e0

Please sign in to comment.