# Fast calculation of eigenvalues

**URL:** <https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359>\
**Category:** Numerics\
**Created:** [October 27, 2019, 9:46am UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359 "2019-10-27T09:46:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FujiwaraTakumiEH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fujiwaratakumieh/32/37975_2.png) [@FujiwaraTakumiEH](https://discourse.julialang.org/u/FujiwaraTakumiEH)\
**Post date:** [October 27, 2019, 9:46am UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/1 "2019-10-27T09:46:13Z")

</div>

### Background:

Now I have a symmetric matrix `A`. I need to find the first `n` eigenvalues and eigenvectors. (I have not actually started to write code, but in the algorithm process I observed the need to solve the eigenvalues and eigenvectors of matrix `A`.)

On the details of matrix `A`:

- `A` should be a [Laplace matrix](https://en.wikipedia.org/wiki/Laplacian_matrix).
- The size of `A` may be 100,000 × 100,000.
- `A` is a symmetric positive semidefinite matrix.
- The matrix `A` that I get from calculation is usually dense, and it is not a sparse matrix.  
(If you have some suggestions for solving sparse matrix in the same situation, it is also possible)

### Question:

My question is **which method can be used for quick solution**? (including parallel computing with GPU or multi-core processor)

So far as I know, there are the following ways to achieve my goal in Julia:

- using `LinearAlgebra`: `eigvals(A)` and `eigvecs(A)`
- using `Arpack`: `eigs(A)`
- using `KrylovKit`: `eigsolve(A)`

At present, I don’t know which of the three methods is the fastest (for large symmetric matrix). Or is there any faster calculation method besides the above methods?

Any reply is highly appreciated! 😀

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 27, 2019, 11:23am UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/2 "2019-10-27T11:23:37Z")

</div>

Properties of the matrix?

---

<div class="post-metadata">

**Author:** ![FujiwaraTakumiEH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fujiwaratakumieh/32/37975_2.png) [@FujiwaraTakumiEH](https://discourse.julialang.org/u/FujiwaraTakumiEH)\
**Post date:** [October 27, 2019, 11:40am UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/3 "2019-10-27T11:40:50Z")

</div>

Sorry for the lack of detailed information 😅, I’ve updated the questions so far.

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [October 27, 2019, 12:24pm UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/4 "2019-10-27T12:24:06Z")

</div>

The important point is: is it sparse or dense? If dense, you can’t easily beat `eigen`. If it’s sparse and you only need a couple of eigenpairs, use Lanczos from Arpack/KrylovKit, or LOBPCG from IterativeSolvers.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 27, 2019, 2:03pm UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/5 "2019-10-27T14:03:59Z")

</div>

Also, “large” is somewhat subjective, so it would be useful to know the typical size.

An MWE with a function that generates a matrix that reflects the structure of your matrix may result in more concrete answers.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<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:** [October 27, 2019, 5:12pm UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/6 "2019-10-27T17:12:12Z")

</div>

You have the option `ishermitian` in `KrylovKit.jl`. It should not speed things up too much though.

---

<div class="post-metadata">

**Author:** ![FujiwaraTakumiEH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fujiwaratakumieh/32/37975_2.png) [@FujiwaraTakumiEH](https://discourse.julialang.org/u/FujiwaraTakumiEH)\
**Post date:** [October 28, 2019, 1:24am UTC](https://discourse.julialang.org/t/fast-calculation-of-eigenvalues/30359/7 "2019-10-28T01:24:10Z")

</div>

Thank you for your advice, I have updated the question. 😀
