0

I'm conducting dimensional reduction of a square matrix A. My issue now is that I have problem computing eigvalue decomposition of a 13000 x 13000 matrix A, i.e. [v d]=eigs(A). Because it's a sparse matrix, I get 'out of memory error' using a 4GB RAM. I'm convinced it's not my PC's problem, since the memory is not used up when eigs command is run. The help I saw online had to do with ARPACK. I checked the recommended site, but there were a lot of files there, don't know which to download. Also, I did not understand how to use it with MATLAB. Another help says use numerical methods, but I dont know which specific one to use. Please any solution is welcome.

Error in ==> eigs>ishermitian at 1535
tf = isequal(A,A');

Error in ==> eigs>checkInputs at 479
            issymA = ishermitian(A);

Error in ==> eigs at 96
[A,Amatrix,isrealprob,issymA,n,B,classAB,k,eigs_sigma,whch, ...

Error in ==> labcomp at 20
[vector lambda] = eigs(A) 

Please can I get translation of these errors and how to correct it?

Matthew Simoneau
  • 6,199
  • 6
  • 35
  • 46
pam
  • 37
  • 1
  • 1
  • 6
  • similar question: http://stackoverflow.com/questions/3181593/matlab-is-running-out-of-memory-but-it-should-not-be – Amro Jul 11 '11 at 12:40
  • By default `eigs(.)` returns only 6 largest eigenvalues and associated eigenvectors. This should not be a memory problem. How much memory your `A` takes, i.e. how sparse it really is? Thanks – eat Jul 11 '11 at 14:35
  • I can't really give you a complete answer because I don't know the nuances of this problem, but I usually use singular value decomposition with I need eigen decomposition of very large arrays. Check out the `SVD` function in MATLAB. – thron of three Jul 11 '11 at 14:53
  • it takes up about 616MB of memory; @thron of three,I have used SVD but I still got the same error, however the outputs of eig and SVD are not the same. – pam Jul 11 '11 at 21:55
  • @pam the svd method of obtaining eigenvalues and vectors will give the exact same output as the eigs function. I have used this for a few papers on data extraction, you need to make sure you are inputting a normalized covariance matrix, not the data matrix. – thron of three Jul 12 '11 at 21:25

2 Answers2

3

The reason you don't see the memory used up, is that it isn't used up - Matlab fails to allocate the needed amount of memory.

Although an array of 13000 x 13000 doubles (the default data type in Matlab) is about 1.25 GB, it doesn't mean a 4Gb of ram is enough - Matlab need 1.25Gb of contiguous memory, otherwise it won't succeed in allocating your matrix. You can read more on memory problems in Matlab here: http://www.mathworks.com/support/tech-notes/1100/1106.html

You can as a first step try using single precision:

[v d]=eigs(single(A));

You say

another help says use numerical methods

If you are doing it on the computer, it's numerical by definition.

If you dont' want (or can't due to memory constraints) to do it in Matlab, you can look for a linear algebra library (ARPACK is just one of them) and have the calculation done outside of Matlab.

Amro
  • 123,847
  • 25
  • 243
  • 454
Itamar Katz
  • 9,544
  • 5
  • 42
  • 74
  • Thanks for your response, I did convert it to data class 'single', but its still giving the same error.For the ARPACK, if there is any tips on how to implement it, please I will appreciate cos I have seen some, but did not understand it. – pam Jul 11 '11 at 11:57
  • Each library usually has some documentation/examples/user guides. Some are more detailed, some are less. You should download the library, look around in the documentation and try to find some code examples. In ARPACK, see for example: http://www.caam.rice.edu/software/ARPACK/UG/node22.html#SECTION00630000000000000000 – Itamar Katz Jul 11 '11 at 12:08
0

First if A is sparse, single(A) won't work. Single sparse matrices are not implemented in MATLAB, see comments: how to create a single float sparse matrix in mex files

The call to ishermitian may fail because you can't store two copies of your matrix (A and A'). Bypass this problem by commenting the line out and setting issymA to true or false, depending on whether your matrix is Hermitian.

If you find further problems with memory inside eigs, try to reduce its memory footage by asking less solutions, eigs(A,1), or reducing the maximum size of the basis (option p), which by default is twice the number of asked solutions:

 opts.p = 3
 [x,d] = eigs(A,2,'LM',opts)
Community
  • 1
  • 1
Eloy
  • 21
  • 4