Jutho / KrylovKit.jl

Krylov methods for linear problems, eigenvalues, singular values and matrix functions
Other
284 stars 37 forks source link

eigsolve returns incorrect results #12

Closed nrontsis closed 5 years ago

nrontsis commented 5 years ago

I notice that sometimes eigsolve returns incorrect results. Below you can find a minimal example:

Download error.jld2 and run:

using JLD2
using KrylovKit
using Arpack

@load "error.jld2" A
println("Real part of rightmost eigevalue")
println(string("Direct: ", maximum(real(eigvals(A)))))

λ, V, info = eigsolve(A, howmany=1, which=:LR)
println(string("KrylovKit: ", maximum(real(λ))))

λ, V, _ = eigs(A, nev=1, which=:LR)
println(string("Arpack: ", maximum(real(λ))))

which produces the following output

Real part of rightmost eigevalue:
Direct: 0.15369067701327851
KrylovKit: -10.02637671173757
Arpack: 0.15369067701327957

on Julia version: 1.0.1 KrylovKit.jl version: latest master (28d74fd)

Apologies for reporting issues without participating in fixing them. I hope that, in the future, I will be able to help more.

Jutho commented 5 years ago

No problem, thanks for reproducible errors.

Preliminary finding: howmany and which are not keyword arguments, so if you use eigsolve(A, 1, :LR) you get the correct result. I guess the syntax eigsolve(A, howmany=1, which=:LR) passes howmany and which as keyword arguments, which are subsequentially ignored by the way I process keyword arguments, and the default choice which=:LM is used.

nrontsis commented 5 years ago

Ah, I see. My bad, thanks for the explanation.

Jutho commented 5 years ago

I guess there could be an error message for this, although I do occasionally like to pass a bunch of keyword arguments around, even if some of them do not apply to the actual method. That's why I am currently ignoring unknown keyword arguments.