MATLAB: SVDS– what is the point of using it and is it ever faster than SVD?

svds

My program finds the eigenvalues of a bunch of matrices and adds them together. But the matrices can get really big and sparse, and this adds to my computation time. I'm using the function SVD to get the eigenvalues, so I tried using the sparse version, SVDS, since I only need the biggest eigenvalues anyway. This wasn't any faster. In fact, I think it's SLOWER! If this is the case, I don't see why SVDS exists. I need to find a sparse matrix operation that will reduce my computation time. Thanks!

Best Answer

Really big means millions by millions. I use the sparse type for the matrix, but still it doesn't seem to speed things up.
I assume the comparison between SVD and SVDS that you're performing is on a scaled down version of this matrix. There is no way a "millions by millions" matrix can be stored in anything but sparse type and there is no way you can be running SVD on a sparse type matrix (it would return an error).
If your tests are based on small scale versions of your actual matrix, we need to ask how small. Definitely the gains in SVDS over SVD won't be seen if your examples are too small, e.g.,
>> N=100; As=speye(N);A=eye(N); tic; svd(A); toc ; tic; svds(A); toc
Elapsed time is 0.001177 seconds.
Elapsed time is 0.006077 seconds.
but there are clearly also examples where svds is better, e.g.,
>> N=5000; As=speye(N);A=eye(N); tic; svd(A); toc ; tic; svds(A); toc
Elapsed time is 47.876229 seconds.
Elapsed time is 0.324260 seconds.