Eigenvectors of sparse symmetric matrix
![](https://secure.gravatar.com/avatar/ea45652ca0f4d70d2c1c8cb16acdaa56.jpg?s=120&d=mm&r=g)
Hi everyone, I am trying to compute the eigenvectors corresponding to the d+1 smallest eigenvalues of A=W.T*W. I started with W as a dense matrix and then W = sparse.csr_matrix(W) A = W.dot(W) # W.T * W W,V = eigen_symmetric(A,d+1, which='SM') The biggest problem is that the algorithm fails to converge and I get all zeros as eigenvectors for a testing dataset. Using dense SVD I got the expected results. The second problem is that this sparse version is much slower than the dense version as u,s,vh = svd(W) The testing data only has 1000x1000, while I expect the real data will have millions by millions of entries. Each row will have only a dozen to at most dozes of non-zero entries. Thanks, Hao
![](https://secure.gravatar.com/avatar/4d9d32e5bde7fe6f68de617ac336e2a7.jpg?s=120&d=mm&r=g)
On Oct 24, 2010, at 6:42 PM, Hao Xiong wrote:
I am trying to compute the eigenvectors corresponding to the d+1 smallest eigenvalues of A=W.T*W. I started with W as a dense matrix and then W = sparse.csr_matrix(W) A = W.dot(W) # W.T * W W,V = eigen_symmetric(A,d+1, which='SM')
The biggest problem is that the algorithm fails to converge and I get all zeros as eigenvectors for a testing dataset. Using dense SVD I got the expected results.
What operating system are you using? The sparse eigensolvers have some issues on 64-bit OS-X (see http://projects.scipy.org/scipy/ticket/1220). I am currently having similar issues. Oddly enough, I get reasonable results if I convert the matrix from the native float64 to the float32 data type. If you are on a 64 bit system, could you try that and let me know if it changes anything? For example, define A as A = W.dot(W).astype(numpy.float32) Best, Lutz
![](https://secure.gravatar.com/avatar/ea45652ca0f4d70d2c1c8cb16acdaa56.jpg?s=120&d=mm&r=g)
I am on 64-bit Linux. I will try float32. Don't know if this matters but the data originally are integers, 0, 1, and 2. They are the encoding of genotypes. Regards, Hao On 10/24/2010 08:26 PM, Lutz Maibaum wrote:
On Oct 24, 2010, at 6:42 PM, Hao Xiong wrote:
I am trying to compute the eigenvectors corresponding to the d+1 smallest eigenvalues of A=W.T*W. I started with W as a dense matrix and then W = sparse.csr_matrix(W) A = W.dot(W) # W.T * W W,V = eigen_symmetric(A,d+1, which='SM')
The biggest problem is that the algorithm fails to converge and I get all zeros as eigenvectors for a testing dataset. Using dense SVD I got the expected results.
What operating system are you using? The sparse eigensolvers have some issues on 64-bit OS-X (see http://projects.scipy.org/scipy/ticket/1220).
I am currently having similar issues. Oddly enough, I get reasonable results if I convert the matrix from the native float64 to the float32 data type. If you are on a 64 bit system, could you try that and let me know if it changes anything? For example, define A as
A = W.dot(W).astype(numpy.float32)
Best,
Lutz
![](https://secure.gravatar.com/avatar/da3a0a1942fbdc5ee9a9b8115ac5dae7.jpg?s=120&d=mm&r=g)
Sun, 24 Oct 2010 18:42:14 -0700, Hao Xiong wrote:
I am trying to compute the eigenvectors corresponding to the d+1 smallest eigenvalues of A=W.T*W. I started with W as a dense matrix and then W = sparse.csr_matrix(W) A = W.dot(W) # W.T * W
That is W*W and not (W.T)*W
W,V = eigen_symmetric(A,d+1, which='SM')
The biggest problem is that the algorithm fails to converge and I get all zeros as eigenvectors for a testing dataset. Using dense SVD I got the expected results.
You can try playing with setting the maxiter parameter to allow ARPACK to spend more iterations on the problem. -- Pauli Virtanen
![](https://secure.gravatar.com/avatar/00f1df105bf89379b330ab4f657defef.jpg?s=120&d=mm&r=g)
On 25 October 2010 06:03, Pauli Virtanen <pav@iki.fi> wrote:
Sun, 24 Oct 2010 18:42:14 -0700, Hao Xiong wrote:
I am trying to compute the eigenvectors corresponding to the d+1 smallest eigenvalues of A=W.T*W. I started with W as a dense matrix and then W = sparse.csr_matrix(W) A = W.dot(W) # W.T * W
That is W*W and not (W.T)*W
Just quickly: is your matrix really symmetric? This could lead to all sorts of bizarre failures to converge. Anne
participants (4)
-
Anne Archibald
-
Hao Xiong
-
Lutz Maibaum
-
Pauli Virtanen