# Suggestions needed: diagonalizing large Hermitian sparse matrix

**URL:** <https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580>\
**Category:** General Usage\
**Tags:** question, linearalgebra, sparse, arpack\
**Created:** [March 25, 2023, 12:34am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580 "2023-03-25T00:34:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [March 25, 2023, 12:34am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580/1 "2023-03-25T00:34:24Z")

</div>

I need to find a few eigenvalues and eigenvectors of some large Hermitian sparse matrices. Right now, I am trying `Arpack.jl` and `KrylovKit.jl`. Here are some considerations and my experiences.

1. `Arpack.jl` does not have special routines for Hermitian matrices, and is less stable than `KrylovKit.jl`.
2. With moderate size, multithreading works pretty good. For example, my CPU usage (from `top` comand) of my Julia process is roughly 2000% for `Arpack.jl` diagonalizing 30624x30624 matrices (sparsity 0.005). However, when the matrices become larger (3 million by 3 million, sparsity 0.00012), the CPU usage of both `Arpack.jl` and `KrylovKit.jl` drops to roughly 200%.
3. Right now, `KrylovKit.jl` takes 2200 seconds to diagonalize a 2883289x2883289 matrix with sparsity 0.00012 and `Arpack.jl` needs more than 1 hour.

Eventually, I would like to diagonalize a 30000000x30000000 matrix with sparsity of roughly 0.00003. What would be your suggestions to attack such a problem?

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [March 25, 2023, 5:38am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580/2 "2023-03-25T05:38:14Z")

</div>

Sorry I don’t have a reply for you, but I was wondering if you could also compare [ArnoldiMethod.jl](https://github.com/JuliaLinearAlgebra/ArnoldiMethod.jl) with the other two? It’s the Julia equivalent to Arpack.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [March 25, 2023, 8:39am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580/3 "2023-03-25T08:39:55Z")

</div>

Just to be sure you just compute a few eigen elements?

Also I think that sparse \* vec is not threaded

---

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [April 3, 2023, 6:02am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580/4 "2023-04-03T06:02:01Z")

</div>

I tested both `KrylovKit.jl` and `ArnoldiMethod.jl` with a 2882954 \times 2882954 Hermitian matrix (sparsity: 0.00012). The results are

- `KrylovKit.jl`: 4783.532569246 seconds
- `ArnoldiMethod.jl`: 3528.127798565 seconds.

The time for `KrylovKit.jl` is different from what I got in my original post. Possible cause: 1. This is a different matrix; 2. I probably asked for more eigenvalues this time (`nev=10`).

---

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [April 3, 2023, 6:03am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580/5 "2023-04-03T06:03:37Z")

</div>

I just need a few eigenvalues. I think that’s the common case for sparse linear algebra.
