I have a very long vector 1xr v and a very long vector w 1xs, and the matrix A rxs, which is sparse (but very large in size).
I expected Matlab to optimize as follows: I will not run into memory issues:
A./(v'*w)
but it looks like Matlab is actually trying to generate the full v'*w matrix, because I have a memory problem. Is there any way to overcome this? Note that there is no need to calculate all v'*w , because many values โโof A are 0 .
EDIT: if it were possible, one way to do this would be to do A(find(A))./(v'*w)(find(A));
but you cannot select a subset of the matrix ( v'*w in this case) without first calculating it and putting it in a variable.
matrix matlab sparse-matrix
kloop
source share