# Arpack is too slow?

**URL:** <https://discourse.julialang.org/t/arpack-is-too-slow/59945>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 24, 2021, 6:28pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945 "2021-04-24T18:28:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 24, 2021, 6:28pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/1 "2021-04-24T18:28:30Z")

</div>

Hi everyone.  
I have a code for computing Surface Wave dispersion velocity (seismology) and it takes about 6 s to run. Of those, 4.5 s are spent on this for loop that calls Arpack to solve the generalised eigenvalue and eigenvector problem (I need both) many times.

```julia
for o=1:fnum
    dp,xp=eigs(A,B,nev=3,sigma=ω[o]/rspd);
    x[:,:,o] = real.(xp);
    d[:,:,o] = real.(dp);
end

```

After some testing the fastest way is to use skip more inputs (tol, which, etc).

A and B are 972x972 sparse matrixes (symmetric but none diagonal ) that are build on each iteration. But the total time of building them is around 0.15 s, so it is not THAT bad.

I wonder if you guys know a faster way to run this line… or if there is a faster alternative in another package.

---

<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:** [April 24, 2021, 9:02pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/2 "2021-04-24T21:02:39Z")

</div>

You want the largest eigenvalues? That is the default when `which` is not given…

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 24, 2021, 9:55pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/3 "2021-04-24T21:55:09Z")

</div>

> [@marianoarnaiz](#):
>
> I have a code for computing Surface Wave dispersion velocity (seismology) and it takes about 6 s to run. Of those, 4.5 s are spent on this for loop that calls Arpack to solve the generalised eigenvalue and eigenvector problem (I need both) many times.

Are you including the compilation time that happens when you run it the first time? (Are you running Julia as a “script”, re-launching Julia each time you do a new calculation?) Are you benchmarking in global scope? Did you read the [performance tips?](https://docs.julialang.org/en/v1/manual/performance-tips/)

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 25, 2021, 11:38am UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/4 "2021-04-25T11:38:28Z")

</div>

Yes. LM is what I want

---

<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:** [April 25, 2021, 12:35pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/5 "2021-04-25T12:35:55Z")

</div>

Well, you get the LM of the invert no? so SM in fact.

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 25, 2021, 1:17pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/6 "2021-04-25T13:17:00Z")

</div>

The full time of the code is re-running the main code in Julia Pro Repel (@time).

The time of the for loop is running that in the Repel.

I checked the perfomance tips… but I don’t thing of the @ helped.

---

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 25, 2021, 1:21pm UTC](https://discourse.julialang.org/t/arpack-is-too-slow/59945/7 "2021-04-25T13:21:26Z")

</div>

You got me here… just got the largest ones… right?
