%%% This program compares the time required to compute a matrix-matrix
%%% product A = B*C where all matrices are of size n x n. 

function hw01p3

rng(0)

%%% Set basic problem parameters.
n = 1000;
B = randn(n,n);
C = randn(n,n);

%%% First compute A as a sequence of matrix-vector products.
A = zeros(n);
tic
for i = 1:n
  A(:,i) = B*C(:,i);
end
fprintf(1,'Time required = %7.3f sec\n',toc)

%%% Next compute A as a simply a matrix-matrix product.
tic
A = B*C;
fprintf(1,'Time required = %7.3f sec\n',toc)

return