# " Adjusting nev from # to # ". eigs() on a Sparse Array using Arpack

**URL:** <https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 5, 2019, 4:04am UTC](https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163 "2019-08-05T04:04:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adan/32/9770_2.png) [@Adan](https://discourse.julialang.org/u/Adan)\
**Post date:** [August 5, 2019, 4:04am UTC](https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163/1 "2019-08-05T04:04:59Z")

</div>

Hi there!  
I’m trying to solve an eigenvalues problem. Originally I have a 792x792 matrix that I turned into a Sparse Array. For that purpose I’m using Arpack and eigs( ). The dimension of that array is 792 so I expect that number of eigenvalues, but I get 791. I’m specifying de number of eigenvalues (nev = 792), but I get this warning:

> ┌ Warning: Adjusting nev from 792 to 791  
> └ @ Arpack ~/.julia/packages/Arpack/UiiMc/src/Arpack.jl:99

I mean, I tried the same in Mathematica and I got 792 values without any problem.  
My code is some heavy, so I made another one with a 3x3 array. And I get the same problem.

```julia
using Arpack
foo = [[1, 2, 3] [5, 6, 7] [8, 9, 10]] #dummy array
eigs(foo, nev = 3)[1] #I know and I tried in Mathematica this one and I got 3 eigenvalues

```

But the same warning appears again!

> ┌ Warning: Adjusting nev from 3 to 1  
> └ @ Arpack ~/.julia/packages/Arpack/UiiMc/src/Arpack.jl:99

Does anyone know why I’m getting less eigenvalues that I expect?  
Is there any way to avoid that auto adjusting of the nev?

By the way, I’m using version 1.1.0 of Julia on my Mac.

Thank you!

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [August 5, 2019, 5:41am UTC](https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163/2 "2019-08-05T05:41:01Z")

</div>

You don’t need sparse matrices or arpack for a matrix that small - just use standard dense linear algebra in the LinearAlgebra standard library.

---

<div class="post-metadata">

**Author:** ![Adan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adan/32/9770_2.png) [@Adan](https://discourse.julialang.org/u/Adan)\
**Post date:** [August 6, 2019, 6:19am UTC](https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163/3 "2019-08-06T06:19:01Z")

</div>

Yes, I totally agree with you. But 792 is just one case, my code should be able to solve arrays of bigger dimensions than that, in some cases I will need Sparse Arrays to deal with a lot of zeros. That’s my point.  
For that reason I’m looking for a way to get all my eigenvalues from a Sparse Matrix.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [August 6, 2019, 7:06am UTC](https://discourse.julialang.org/t/adjusting-nev-from-to-eigs-on-a-sparse-array-using-arpack/27163/4 "2019-08-06T07:06:36Z")

</div>

AFAIK, ARPACK simply isn’t made for what you’re asking. It is a tool to calculate a bunch of extremal eigenvalues for huge sparse matrices and not for calculating all of them. Getting all eigenvalues of a large sparse matrix is an expensive problem!

Anyways, there are iterative solvers implemented in Julia that give you what you want. For example, using [KrylovKit.jl](https://github.com/Jutho/KrylovKit.jl) I get:

```julia
julia> using KrylovKit

julia> foo = [[1, 2, 3] [5, 6, 7] [8, 9, 10]];

julia> eigvals(foo) # using Julia's regular solver
3-element Array{Float64,1}:
 18.15660395791398
 -1.1566039579139824
  5.197454115860898e-16

julia> λ, ϕ = eigsolve(sparse(foo)); # using KrylovKit

julia> λ
3-element Array{Complex{Float64},1}:
      18.156603957913973 + 0.0im
      -1.156603957913983 + 0.0im
 -3.1400729958893956e-16 + 0.0im

```

See also [IterativeSolvers.jl](https://github.com/JuliaMath/IterativeSolvers.jl) and [ArnoldiMethod.jl](https://github.com/haampie/ArnoldiMethod.jl) for alternatives.
