# "ARPACKException: unspecified ARPACK error" when doing SVD of sparse matrix

**URL:** https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753
**Category:** General Usage
**Created:** [April 4, 2019, 2:31pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753 "2019-04-04T14:31:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [April 4, 2019, 2:31pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/1 "2019-04-04T14:31:30Z")

</div>

I get the error ARPACKException: unspecified ARPACK error: when trying to find the SVD of a sparsematrix tildeK.

> SVD = svds(tildeK, nsv=2)[1];  
> ERROR: ARPACKException: unspecified ARPACK error: 1  
> Stacktrace:  
> [1] aupd\_wrapper(::Type, ::getfield(Arpack, Symbol(“#matvecA!#24”)){Arpack.AtA\_or\_AAt{Float64,SparseMatrixCSC{Float64,Int64}}}, ::getfield(Arpack, Symbol(“##18#25”)), ::getfield(Arpack, Symbol(“##19#26”)), ::Int64, ::Bool, ::Bool, ::String, ::Int64, ::Int64, ::String, ::Float64, ::Int64, ::Int64, ::Array{Float64,1}) at /home/dass/.julia/packages/Arpack/UiiMc/src/libarpack.jl:49  
> [2] #\_eigs#17(::Int64, ::Int64, ::Symbol, ::Float64, ::Int64, ::Nothing, ::Array{Float64,1}, ::Bool, ::typeof(Arpack.\_eigs), ::Arpack.AtA\_or\_AAt{Float64,SparseMatrixCSC{Float64,Int64}}, ::UniformScaling{Bool}) at /home/dass/.julia/packages/Arpack/UiiMc/src/Arpack.jl:198  
> [3] #\_eigs at ./none:0 [inlined]  
> [4] #eigs#10 at /home/dass/.julia/packages/Arpack/UiiMc/src/Arpack.jl:63 [inlined]  
> [5] #eigs at ./none:0 [inlined]  
> [6] #\_svds#37(::Int64, ::Bool, ::Float64, ::Int64, ::Int64, ::Array{Float64,1}, ::Function, ::SparseMatrixCSC{Float64,Int64}) at /home/dass/.julia/packages/Arpack/UiiMc/src/Arpack.jl:325  
> [7] (::getfield(Arpack, Symbol(“#kw##svds”)))(::NamedTuple{(:nsv,),Tuple{Int64}}, ::typeof(svds), ::SparseMatrixCSC{Float64,Int64}) at ./none:0  
> [8] top-level scope at none:0

---

<div class="post-metadata">

### Author: ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)
#### Post date: [April 4, 2019, 7:09pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/2 "2019-04-04T19:09:02Z")

</div>

Are you able to post code to generate the matrix `tildeK` and thereby create a MWE? Also, which version of julia are you on? `svds(tildeK, nsv=2)[1];` works fine for me on Linux, julia 1.1, Arpack.jl v0.3.0 using a random 100 X 100 real SPD sparse matrix.

Edit: I’m not too familiar with Arpack itself or Arpack.jl. You might want to double check that your matrix type is supported.

---

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [April 4, 2019, 7:20pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/3 "2019-04-04T19:20:33Z")

</div>

I am on v1.1.0. tildeK is a sparse square matrix of size 70000, with about 8 entries in each row. Thus is it is very very sparse and there is no danger of running out of RAM. It is difficult to describe the construction of tildeK, it is built from a Gaussian kernel on a data-set.

If I could know what the error code means, I could figure out what is wrong. The error message is too cryptic at the moment.

But it seems to be a deficiency in the Julia SVD algorithm. tildeK is very sparse and very close to an identity matrix. The number of singular pairs I am asking for is also very low (2).

---

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [April 4, 2019, 8:05pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/4 "2019-04-04T20:05:44Z")

</div>

Also, Arpack seems to be the only package to perform the svd of a sparse matrix, isn’t it ? The svd method from the LinearAlgebra package doesn’t work.

> julia\> SVD = LinearAlgebra.svd(tildeK, nsv=2);  
> ERROR: MethodError: no method matching svd(::SparseMatrixCSC{Float64,Int64}; nsv=2)  
> Closest candidates are:  
> svd(::BitArray{2}) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/bitarray.jl:90 got unsupported keyword argument “nsv”  
> svd(::LinearAlgebra.AbstractTriangular) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/triangular.jl:2471 got unsupported keyword argument “nsv” …

---

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [April 4, 2019, 8:39pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/5 "2019-04-04T20:39:22Z")

</div>

> [@iamsuddhasattwa](#):
>
> Also, Arpack seems to be the only package to perform the svd of a sparse matrix, isn’t it ?

Maybe [KrylovKit.jl](https://github.com/Jutho/KrylovKit.jl) can help?

---

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [April 7, 2019, 2:26pm UTC](https://discourse.julialang.org/t/arpackexception-unspecified-arpack-error-when-doing-svd-of-sparse-matrix/22753/6 "2019-04-07T14:26:38Z")

</div>

Thank you for the suggestion. I am testing it.
