function []=hw4_2_8() % perform the Cholesky decomposition on a matrix as a sparse matrix and as a full % matrix with eigenvalues r. r=[3:2:21]; A=sprandsym(10,0.2,r); % try timing instead of flops tic C=chol(A); t1=toc; disp('sparse time') disp(t1) % convert to a full matrix and retime fA=full(A); tic fC=chol(fA); t2=toc; disp('full time') disp(t2) % the only reason the sparse time is longer is because the sparse computation is % done first, so when the full decomposition is computed it already "knows" the % answer