This section might be useful:
Suppose you want to multiply each column of a very large matrix by the same vector. There is a way to do this using sparse matrices that saves space and can also be faster than matrix construction...
F = rand(1024,1024);
X = rand(1024,1);
Y = F * diag(sparse(X));
Y = diag(sparse(X)) * F;
On the other hand, most of times bsxfun would be a more efficient solution.
No comments:
Post a Comment