Getting KrylovKit to return specified number of values

I’m working on a problem (reduced order models of circuits) and am trying to use KrylovKit to return a specified number of eigenvalues in the solution. I couldn’t make it work, but it was easy in Arpack

x = eigs(a, nev=3)

where a is a 6x6 matrix. it returned the 3 largest eigenvalues as expected - the other 3 eigenvalues are much smaller.

however I can’t seem to find the correct way to invoke the same thing using KrylovKit, for example

x = eigsolve(a, 3)

is what i would think it should be from the documentation, but it returns all 6 eigenvalues, not the 3 largest. in fact, it should only return 1 if you don’t supply any arguments (other than the matrix), but it still returns all 6.

Here is the invocation,

eigsolve(A::AbstractMatrix, [x₀, howmany = 1, which = :LM, T = eltype(A)]; kwargs...)

I was wondering if someone could help me figure out the correct application.

I suppose this would be a good time to ask if there is any advantage in using KrlyovKit for this problem instead of Arpack.

Thank you.

What you’re doing is correct. KrylovKit will sometimes find more eigenvalues than requested. This does not take more time to compute or anything like that, so you can just ignore them. It will always return at least the number you asked for, unless something goes wrong.

In my experience, KrylovKit and Arpack are about the same performance-wise. Sometimes one is faster than the other. The major advantage of KrylovKit is that it can be used with matrices and vectors that are not subtypes of AbstractMatrix and AbstractVector.

Thank you !