How to reduce memory for matrix multiplication?

7 views (last 30 days)
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
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.
  • 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?

Sign in to comment.

Answers (3)

John D'Errico
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.

nilsotto
nilsotto on 23 Mar 2016
That was indeed a lecture. In my daily work I use Ansys FEA where I can switch between different solvers. By use of disk swapping I can solve very large problems with low amount of memory. If it's as you say not possible to divide large mathematical problems, I wonder how Ansys solvers is working?
  1 Comment
Jan
Jan on 23 Mar 2016
ANSYS produces matrices with a known sparse structure. They can be solved efficiently without performing a full matrix multiplication.

Sign in to comment.


Walter Roberson
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.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!