# Getting KrylovKit to return specified number of values

**URL:** <https://discourse.julialang.org/t/getting-krylovkit-to-return-specified-number-of-values/93852>\
**Category:** General Usage\
**Created:** [February 1, 2023, 6:28am UTC](https://discourse.julialang.org/t/getting-krylovkit-to-return-specified-number-of-values/93852 "2023-02-01T06:28:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [February 1, 2023, 6:28am UTC](https://discourse.julialang.org/t/getting-krylovkit-to-return-specified-number-of-values/93852/1 "2023-02-01T06:28:08Z")

</div>

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,

```julia
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.

---

<div class="post-metadata">

**Author:** ![mtsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtsch/32/2072_2.png) [@mtsch](https://discourse.julialang.org/u/mtsch)\
**Post date:** [February 3, 2023, 9:55pm UTC](https://discourse.julialang.org/t/getting-krylovkit-to-return-specified-number-of-values/93852/2 "2023-02-03T21:55:16Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [February 3, 2023, 11:14pm UTC](https://discourse.julialang.org/t/getting-krylovkit-to-return-specified-number-of-values/93852/3 "2023-02-03T23:14:59Z")

</div>

Thank you !
