0

I use the MATLAB to do eigenvalue decomposition, and the dimension of data is about 10000, so the covariance matrix is 10000*10000. When I use the eig() function in MATLAB, it is very slow. Is there any way to speed up the eigenvalue decomposition. I use the eigenvalue decomposition to do principal component analysis(PCA), so I just use the top K eigenvalues and eigenvectors. There is no need to get all the eigenvalues and eigenvectors. I have tried to use the Intel-MKL to do eigen decomposition, but when I use the mex interface, there are some errors. I posted it in the link https://stackoverflow.com/questions/19220271/how-to-use-intel-mkl-for-speed-my-own-matlab-mex-cpp-applications

Please give me some advice, Thanks.

Community
  • 1
  • 1
mining
  • 3,557
  • 5
  • 39
  • 66

1 Answers1

2

use eigs if your data is sparse, or if you are interested in the first k values. For example, eigs(A,k) returns the k largest magnitude eigenvalues. Note that eigs will be faster only for the first few eigen-values, and will be slower for k > some value (probably 5...)

bla
  • 25,846
  • 10
  • 70
  • 101
  • Ok, Thanks. But I want to use c++, because MATLAB is non free. – mining Oct 08 '13 at 04:35
  • MKL is not free either, for both research and commercial purposes. – kangshiyin Oct 08 '13 at 04:49
  • Then, do I need write the `eig` function by myself? I know some open source libraries for these computation, such as OpenBLAS, LAPACK, etc. But they have no invokable `eig` function. – mining Oct 08 '13 at 05:31
  • 1
    LAPACK definetely has routines for eigenvalues and eigenvectors (or check Armadillo library to get more C++-like interface). You can use GNU Octave also – Dmitry Galchinsky Oct 08 '13 at 07:48
  • @nathan - `eigs(A,k)` is not only less accurate than `eig(A)` but also slower. Test it and see for yourself. – Yair Altman Oct 11 '13 at 11:40
  • Of course `eigs` will be less accurate, but if are only interested in the first 2-3 eigen values, I disagree for it being slower. More than that, sure, but that's what I tried to say in the answer. Since that wasn't delivered I'll edit the answer to make clear. – bla Oct 11 '13 at 18:13