MATLAB: Large Matrix multiplication and out of memory error in matlab

large matrix multiplicationlarge vector multiplicationout of memory error in matlab

i have sparse matrix V of size V =<162000×32400 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.

Best Answer

Hi Imran,
here an update taking care of the "not multiple" issue:
n = size(V,2);
blksize = 500;
result = zeros(n);
for i=0:(n/blksize-1)
columns = i*blksize + (1:blksize);
result(:, columns) = V'*V(:,columns) + y_0*y_0(columns)';
end
% n not a multiple of blksize?
if columns(end)
columns = (columns(end)+1):n;
result(:, columns) = V'*V(:,columns) + y_0*y_0(columns)';
end
Again, you will need to play with the blksize (which now is indeed a blksize not like above a number of blocks) ...
Titus