1
$\begingroup$

I've been using LAPACK dgeev in FORTRAN in the last months spending hours to diagonalize ~4000*4000 matrices. It takes about 2'75 hours to find eigenvalues and eigenvectors this way. I thought FORTRAN should be faster than Mathematica as it usually is for this kind of tasks. After all this hard work and coding effort I have just realized Mathematica does the same in <15 minutes. What is happening?

$\endgroup$

3 Answers 3

2
$\begingroup$

The LAPACK/BLAS implementation surely matters, but even with the reference BLAS (via the Numpy python library) it took less than 15 minutes (on a Core i7 laptop) to compute the eigenvalues for a random 4000*4000 real matrix.

Was your matrix real or complex? Are you able to check the performance from eg. R or python, just to exclude the chance of errors in the Fortran code?

$\endgroup$
1
  • $\begingroup$ My matrix is a tridiagonal non-symmetric real matrix. I'm sorry I can not compare with other tools, but if it helps, everything in the code that is not the diagonalization call is analogous in both codes, and the output (eigenvalues and eigenvectors) are the same. $\endgroup$
    – Andrestand
    Sep 29, 2013 at 21:39
4
$\begingroup$

The LAPACK routine dgeev in turn calls routines from the BLAS library to perform more basic linear algebra such as matrix-matrix multiplications. It's likely that the slow performance of dgeev on your problem is caused by using a BLAS library that isn't highly optimized.

Do you know which implementation of BLAS you're using with your Fortran code?

$\endgroup$
1
4
$\begingroup$

dgeev is meant for smallish matrices where you need all eigenvalues. It may be that Mathematica is using a smarter but completely different method, such as Krylov subspace methods to generate the eigenvalues for your matrices.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.