2

I need to compute numerically all the eigenvalues of roughly $500$ large Hermitian matrices, $(5 \times 10^5) \times (5 \times 10^5)$).

At best, I can speed up my computation such that it takes almost twice the amount of time that I can reach on python using the numpy package.

I would like if such a difference can be in general further reduced, and the two performance can be similar, or there is a gap between mathematica an python that I cannot fill.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Dario Rosa
  • 355
  • 1
  • 9
  • That's weird. I thought that both numpy and Mathematica link to the same library (ARPACK). Be sure to use Method->"Arnoldi"; see also documentation of Eigenvalues. – Henrik Schumacher Mar 02 '18 at 08:17
  • Oh thank you. I will try to do some tests on that. But so, on general ground, should I expect to reach the same performance with mathematica and python? thatnks! – Dario Rosa Mar 02 '18 at 08:19
  • Mathematica should perfom some additional copy operations for the transfer to and from the library in order to preserve immutability. But that should be negligible compared to the effort of computing the eigenvalues. Once the matrix is in the library (and the same options are uses), I see now reason why there should be a performance difference. Unfortunately, Mathematica provides only few suboptions for "Arnoldi" to tune it further. Moreover, I don't know to which version of ARPACK they link. – Henrik Schumacher Mar 02 '18 at 08:26
  • I see. Actually from the documentation it seems that Arnoldi method can be used only if we need few eigenvalues but I need all of them. Do you know whether I can overcome this problem? – Dario Rosa Mar 02 '18 at 08:30
  • Doh. Yeah, that is an issue. You can try to compute first and secand half of spectrum separately. Moreover, it just came to my mind that Mathematica might not link to the parallel version of ARPACK =/ – Henrik Schumacher Mar 02 '18 at 08:35
  • I am now quite sure that Mathematica uses a parallel version. Still, the Arnoldi method is not meant for computing all eigenvalues. I use to say: If you try to compute all eigenvalues of such a large matrix (and you expect them to be exact) then you are doing something wrong. However, I don't know what you need them for... – Henrik Schumacher Mar 02 '18 at 08:49
  • Thanks again. Unfortunately for what I am going to do all the eigenvalues are necessary (of course, I do not want the exact values of them). – Dario Rosa Mar 02 '18 at 08:55
  • Then I wish you all the best and good luck for your project. Btw.: I presumed that your matrix is sparse. Is it? – Henrik Schumacher Mar 02 '18 at 09:02
  • good point! they are sparse but when I try to get all the eigenvalues mathematica prefers to convert them to be dense – Dario Rosa Mar 02 '18 at 09:16
  • You may also try Method -> "FEAST". I have to say that I have really few experience with that method. – Henrik Schumacher Mar 02 '18 at 09:24
  • Yes, is what I am trying now. Thank you very much! – Dario Rosa Mar 02 '18 at 09:28
  • You're welcome! – Henrik Schumacher Mar 02 '18 at 09:28

0 Answers0