Large Matrix multiplication and out of memory error in matlab
Afficher commentaires plus anciens
i have sparse matrix V of size V =<162000x32400 double> or even bigger , I have to solve the following equations.
x_0=ones(size(V ,1) ,1);
y_0=V'*x_0;
result=V'*V + y_0*y_0'; %%%%%Problem here
The problem is in right hand side of last equation and is giving me out of memory error.
Réponse acceptée
Plus de réponses (4)
Walter Roberson
le 31 Oct 2011
0 votes
Is y_0=V'*x_0; the same as sum(V) ?
1 commentaire
imran khan
le 31 Oct 2011
Jan
le 31 Oct 2011
0 votes
A [162000x32400] DOUBLE array needs 42GB memory. I'm not sure if computing V'*V + y_0*y_0' needs to allocate one, two or three further blocks of this size as temporary memory. In every case the blocks must be available in contiguos blocks. Therefore I estimate you need 128 to 256 GB free RAM.
How many RAM do you have installed?
(Is V sparse?) [EDITED:] How sparse is V?
3 commentaires
Walter Roberson
le 31 Oct 2011
The problem statement does start by saying V is sparse.
imran khan
le 31 Oct 2011
imran khan
le 1 Nov 2011
Titus Edelhofer
le 31 Oct 2011
0 votes
Hi Imran,
I guess the problem is, that y_0*y0' most likely will be a full matrix, as long as your V matrix has no columns that sum up to zero. This will fail already as Jan pointed out. You might get along by looping over the columns of your matrix V ...
Titus
1 commentaire
imran khan
le 1 Nov 2011
Titus Edelhofer
le 1 Nov 2011
Hi Imran,
something like the following should work:
n = size(V,2);
blksize = 100;
result = zeros(n);
for i=0:(blksize-1)
columns = i*n/blksize + (1:n/blksize);
result(:, columns) = V'*V(:,columns) + y_0*y_0(columns)';
end
I must admit I did not check if it is really correct, but should give an impression (and can be verified easily on small example). The blksize can be experimented for balancing memory and speed.
Titus
3 commentaires
imran khan
le 3 Nov 2011
Titus Edelhofer
le 3 Nov 2011
Hi Imran,
I updated the code (n needs to be the number of columns). by the way, the code assumes, that the number of columns of V is a multiple of the blksize, otherwise one needs to be more careful ...
Titus
imran khan
le 4 Nov 2011
Catégories
En savoir plus sur Linear Algebra 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!