Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eigsolve not working with howmany option #62

Closed
juliohm opened this issue Oct 28, 2022 · 8 comments
Closed

eigsolve not working with howmany option #62

juliohm opened this issue Oct 28, 2022 · 8 comments

Comments

@juliohm
Copy link

juliohm commented Oct 28, 2022

Am I doing something wrong?

julia> KrylovKit.eigsolve(rand(100,100), howmany=2)
ERROR: MethodError: no method matching eigselector(::Matrix{Float64}, ::Type{Float64}; howmany=2)
Closest candidates are:
  eigselector(::AbstractMatrix, ::Type; issymmetric, ishermitian, krylovdim, maxiter, tol, orth, eager, verbosity) at C:\Users\julio\.julia\packages\KrylovKit\kWdb6\src\eigsolve\eigsolve.jl:237 got unsupported keyword argument "howmany"
  eigselector(::Any, ::Type; issymmetric, ishermitian, krylovdim, maxiter, tol, orth, eager, verbosity) at C:\Users\julio\.julia\packages\KrylovKit\kWdb6\src\eigsolve\eigsolve.jl:205 got unsupported keyword argument "howmany"
Stacktrace:
 [1] kwerr(::NamedTuple{(:howmany,), Tuple{Int64}}, ::Function, ::Matrix{Float64}, ::Type)
   @ Base .\error.jl:165
 [2] eigsolve(f::Matrix{Float64}, x₀::Vector{Float64}, howmany::Int64, which::Symbol; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:howmany,), Tuple{Int64}}})
   @ KrylovKit C:\Users\julio\.julia\packages\KrylovKit\kWdb6\src\eigsolve\eigsolve.jl:184
 [3] eigsolve(A::Matrix{Float64}, howmany::Int64, which::Symbol, T::Type; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:howmany,), Tuple{Int64}}})
   @ KrylovKit C:\Users\julio\.julia\packages\KrylovKit\kWdb6\src\eigsolve\eigsolve.jl:176
 [4] top-level scope
   @ REPL[27]:1
@Jutho
Copy link
Owner

Jutho commented Oct 28, 2022

howmany is currently still a positional argument, not a keyword argument. I am considering to change this in a future (breaking) version

@juliohm
Copy link
Author

juliohm commented Oct 28, 2022

I got confused with the docstring then. What about the xo argument? Is there a good recommendation? I understand that the howmany is the 3rd positional argument so we need to specify xo as well.

@Jutho
Copy link
Owner

Jutho commented Oct 28, 2022

Yes you need to specify x0, except when your operator is a matrix. In that case, I can generate a random vector. But KrylovKit works with arbitrary user types as vectors, and arbitrary functions as linear operators. I have no way to know what type of vector the user is using, and I cannot create random instances of it. So you have to specify one instance. Any random instance should be fine, as long as it is not the zero vector. If it is already close to being an eigenvector, than convergence will be faster.

@juliohm
Copy link
Author

juliohm commented Oct 28, 2022

It would be great to make these keyword arguments indeed. Also, the return type of the eigenvectors could be a simple matrix as with other linear algebra packages maybe? I tried to port some code from ArnoldMethod.jl to KrylovKit.jl without success.

Marking the issue as solved.

@juliohm juliohm closed this as completed Oct 28, 2022
@Jutho
Copy link
Owner

Jutho commented Oct 28, 2022

I think you miss the point of this package. Vectors can be any user type that satisfy a minimal interface. In particular; they don't have to be AbstractVector or Vector. As such, concatenating them into a matrix doesn't make sense; a list of eigenvectors is the only sensible return type. If you don't need this functionality and your vectors are simple Vectors, then this package still works, but I don't think it gains you much over Arpack.jl or ArnoldiMethod.jl, and indeed, because of this more general approach, some behaviour might be somewhat different.

@juliohm
Copy link
Author

juliohm commented Oct 28, 2022 via email

@Jutho
Copy link
Owner

Jutho commented Oct 28, 2022

It's a simple matter of doing hcat(vecs...) to get the corresponding matrix in that case.

@juliohm
Copy link
Author

juliohm commented Oct 28, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants