matlab out of memory error when multiplying 2 matrix
Afficher commentaires plus anciens
I have a X = 3*120744 double matrix and I am trying to calculate X'X but getting out of memory error. I have a system with 16G ram. So not sure what's going on. Any idea?
Réponse acceptée
Plus de réponses (1)
Steven Lord
le 5 Mar 2019
With the specified dimensions, the result of X'*X will be size [120744 120744]. Assuming X is a real, full, double matrix that will require a contiguous block of memory of this size:
>> resultsize = [120744 120744];
>> numberOfElements = prod(resultsize);
>> bytes = 8*numberOfElements; % a real double requires 8 bytes
>> gb = bytes/(1024^3)
gb =
108.622860431671
You likely don't have a contiguous block of memory that large.
If you tell us more about the properties of X and why you're trying to compute X'*X (what your ultimate goal is) we may be able to suggest an alternative. If X is sparsely populated, for example, storing it as a sparse matrix may help.
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!