- How large is your "huge matrix"?
- Is your matrix stored as a full matrix or a sparse matrix?
- Is it sparsely populated [few nonzero elements]? This is related to but distinct from the previous question; people sometimes store sparsely populated matrices in full storage or fully nonzero matrices in sparse storage.
- What data type is it?
- Do you have access to Parallel Computing Toolbox? If so, do you also have access to MATLAB Distributed Computing Server?
- Are you using this matrix multiplication to try to solve a system of equations A*x = b by multiplying by the inverse of A? If so, have you tried using the backslash operator and/or an iterative solver like GMRES?
- What operating system and release of MATLAB are you using? Are they 32-bit or 64-bit?
How to reduce memory for matrix multiplication?
7 views (last 30 days)
Show older comments
I guess this is more of a mathematical issue than particually Matlab. I have a matlab app including a huge matrix multiplication that takes up very much memory, which in some cases makes it impossible to run on a common PC. Is there a way to cut the multiplication into smaller pieces in order to reduce required memory.
1 Comment
Steven Lord
on 23 Mar 2016
Edited: Steven Lord
on 23 Mar 2016
If you describe in more detail the problem you're trying to solve you may receive suggestions on alternate approaches you can use to solve it.
Answers (3)
John D'Errico
on 23 Mar 2016
Edited: John D'Errico
on 23 Mar 2016
How can we answer this question? No, you cannot magically use less memory than you need for a computation. You make the decisions about what it is you want to do, what computations will be done. If they take too much memory, then you may just need to solve smaller problems, or you need to get more memory, or a bigger, faster computer.
One alternative is often that in fact, you really don't need to do that memory intensive computation, that you should in fact be doing it in some other way. But again, how can we answer that question? I cannot read your mind to know what it is that you are doing, and that possibly, you have created some hugely inefficient computation for no good reason. (Don't tell me this could not possibly happen. I've seen it done over and over again, sometimes by people who would have assured me they knew what they were doing.)
If we could make big computations into small ones, just by wanting it to be so, we would live in a very different world, and Harry Potter would be our friend.
3 Comments
Walter Roberson
on 23 Mar 2016
There are techniques for doing large memory multiplications with relatively small memory. The techniques may involve swapping to tape or disk.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!