How can I do a memory efficient sparse matrix multiplication?

1 view (last 30 days)
I have a sparse matrix A (dimension 4000000 x 1000000) and I want to calculate the matrix product:
B = A * A'
This results in: "Out of memory. Type HELP MEMORY for your options."
  2 Comments
Cedric
Cedric on 5 Nov 2013
Edited: Cedric on 5 Nov 2013
What is the density or nnz? What is its size in memory (whos), and are you able to evaluate
B = A.' ;
without generating this out of memory error?
Steffen
Steffen on 5 Nov 2013
16891004 non-zero elements in a 4172241 x 1032306 matrix.
density: 3.921729424555354E-6
Yes, I can calculate B = A.' without generating this error.

Sign in to comment.

Answers (1)

Matt J
Matt J on 5 Nov 2013
Edited: Matt J on 5 Nov 2013
If you only plan to use A*A' in matrix multiplication, you might be able to use my ProdCascade class
>> A=sprand(4e6, 1e6,1e-5); c=rand(4e6,1);
>> tic; B=A*A'; B*c; toc;
Out of memory. Type HELP MEMORY for your options.
>> tic; B=ProdCascade({A,A.'}); B*c; toc;
Elapsed time is 7.531522 seconds.
  8 Comments
Steffen
Steffen on 6 Nov 2013
D=C\Y;
E=C\X;
doesn't work because of memory restrictions. I use the pseudoinverse of C to calculate D and E. I wanted to do the gradient descend to improve the C matrix.
Matt J
Matt J on 6 Nov 2013
Edited: Matt J on 6 Nov 2013
If C is full rank, then pinv(C)*Y is equivalent to D=C\Y so iterative minimization shouldn't improve anything.
Since C has only 5 columns, I can't imagine memory restrictions being a problem.

Sign in to comment.

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!