% INPUT % ------------- Populate Matrices --------------- % Declare size of array m = 100; %****************************************************% % rand - returns normally distributed random numbers % between (0.0, 1.0) in an NxN array A = rand(m); B = rand(m); % ---------- Do matrix multiplication ----------- % using optimized matrix multiplication in Matlab tic; C = A*B; t(1) = toc; % using good old-fashioned matrix multiplication D(m,m) = 0.0; tic; for i=1:m for j=1:m for k=1:m D(i,j) = D(i,j) + A(i,k)*B(k,j); end end end t(2) = toc; % ----------------- Find Eigenvalues ------------ % returns a vector of the eigenvalues of matrix A. tic; E = eig(C) t(3) = toc; %*****************************************************% % OUTPUT % - Times ------------------------------------------ % - t(1) matlab matrix multiplication % - t(2) basic matrix multiplication % - t(3) matlab finding eigenvalues m t clear;