||Department of Engineering
Previous: Numerical Analysis
If you know that your matrices will stay nearly empty, then make
them sparse - they'll take up less space and can be operated on
% comparison of sparse vs full matrices
% Create sparse and full versions of the same matrix.
% Note that the density is 0.05. The break-even point
% for this operation seems to be about 0.25.
S = sprandn(60,60,0.05);
F = full(S);
% Compare speed.
B = S * S;
C = F * F;