function times = mbench(testno) % PURPOSE: % This program serves as a benchmark, running a long series of % tests on both "small" ( < 1.5Mb) and "large" (~6Mb) matrices. It % does not test any graphic capabilites (yet?). Note that this % is a rather long test (many days on a P166). Also, I wouldn't % suggest running this benchmark with less than 256Mb of RAM. % % INPUT: % Running "mbench" with no arguments will run all 25 tests. These % are: % TEST 1 - nested FOR loops % TEST 2 - generate random matrices % TEST 3 - fft(A) (A small, real) % TEST 4 - fft(A) (A large, real) % TEST 5 - A+A (A small, real) % TEST 6 - A+A (A large, real) % TEST 7 - A*A (A small, real) % TEST 8 - A*A (A large, real) % TEST 9 - A*A (A small, complex) % TEST 10 - A*A (A large, complex) % TEST 11 - log(A) (A complex) % TEST 12 - Gamma(A) (A real) % TEST 13 - vector sorting % TEST 14 - multidimensional matrix sorting % TEST 15 - inv(A) (A small, complex) % TEST 16 - inv(A) (A large, complex) % TEST 17 - lu(A) (A small, complex) % TEST 18 - lu(A) (A large, complex) % TEST 19 - eig(A) (A small, complex, eigenvalues only) % TEST 20 - eig(A) (A large, complex, eigenvalues only) % TEST 21 - eig(A) (A small, complex) % TEST 22 - eig(A) (A large, complex) % TEST 23 - sparse matrix generator % TEST 24 - sparse lu (A complex, banded) % TEST 25 - eigs(A) % % With a vector argument only the specified tests are performed % e.g. "mbench([1 3 7 20:25])" % % OUTPUT: % The timings of the tests performed (can be saved by running % "t = mbench(testno)", say). % % times.test{n}.name is the name of the test, e.g. "TEST 4" % times.test{n}.avg is the average time it took to perform one operation % times.test{n}.sd is the error in the mean % times.test{n}.tot is the total time is took to perform the test % times.totalflops is the total number of flops % times.mbenchtotal is the total time it took to complete mbench % times.megabogoflops is the most accurate measure of the CPU speed % you will ever see. % % All timings are in seconds. If no arguments are given a % comparison with the benchmarks of a few other machines is shown. % (the results of the comparison are not really meaningful except % as a very crude guide to performance since people usually like % short, sweet answers :) A closer look at each of the individual % timings is what should be done). % % SEE ALSO: % bench.m % % AUTHOR: % Marco De la Cruz-Heredia (marco@atmosp.physics.utoronto.ca) % % Please email me results!!! If you do, state clearly: % - Which version of MATLAB you are using (i.e. type "ver" at the prompt) % - The OS % - The machine's model/vendor % - Model, speed and number of CPUs % - Amount of RAM % - Cache size % - Any other relevant info, e.g. was mbench running by itself? % % I will post the results on the net as they become available % (http://128.100.80.13/marco/matlab/coolplot.html). % % COMMENTS: % Inspired in part by Stefan Steinhaus's (stst@informatik.uni-frankfurt.de) % benchmark (http://www.informatik.uni-frankfurt.de/~stst/ncrunch.html) if (nargin == 0) testno = [1:25]; elseif (length(testno) < 1 | ... length(testno) > 25 | ... any(~isreal(testno)) | ... any(round(testno) ~= testno) | ... max(testno) > 25 | ... min(testno) < 1) error('mbench: testno must be a vector containing the test numbers 1 <= n <= 25') end flops(0); t_0 = 0; % Linear increase in "n" will _not_ lead to a linear % increase in time or memory. n = 3 should do a relatively % quick test (~7 minutes on a 195Mhz MIPS R10000). % Use n > 16 at your own risk :) n = 12; loops = 10*n; pt = 3; if (n > 16) GoOn = input('Warning! n > 16! Continue? y/[n]? ','s') if (strcmp(GoOn,'n') | isempty(GoOn)) times = NaN; return end end if any(testno == 1) lps = loops; N = n; clc; fprintf('TEST 1 - nested FOR loops: %g loops (counter to %g)', lps^5, lps) tic; [time_nfl,sd_nfl] = nfl(N, lps); t_f = toc; fprintf('TEST 1 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{1}.name = 'TEST 1'; times.test{1}.avg = time_nfl; times.test{1}.sd = sd_nfl; times.test{1}.tot = t_f; pause(pt) end if any(testno == 2) lps = 10*loops; N = 100*n; clc; fprintf('TEST 2 - generate random matrices: %g loops', lps) tic; [time_rmg,sd_rmg] = rmg(N, lps); t_f = toc; fprintf('TEST 2 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{2}.name = 'TEST 2'; times.test{2}.avg = time_rmg; times.test{2}.sd = sd_rmg; times.test{2}.tot = t_f; pause(pt) end if any(testno == 3) lps = 100*loops; N = 1000*n; clc; fprintf('TEST 3 - fft(A) (A small): %g loops\n', lps) tic; [time_sffta,sd_sffta] = ffta(N, lps); t_f = toc; fprintf('TEST 3 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{3}.name = 'TEST 3'; times.test{3}.avg = time_sffta; times.test{3}.sd = sd_sffta; times.test{3}.tot = t_f; pause(pt) end if any(testno == 4) lps = loops; N = 50000*n; clc; fprintf('TEST 4 - fft(A) (A large): %g loops\n', lps) tic; [time_lffta,sd_lffta] = ffta(N, lps); t_f = toc; fprintf('TEST 4 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{4}.name = 'TEST 4'; times.test{4}.avg = time_lffta; times.test{4}.sd = sd_lffta; times.test{4}.tot = t_f; pause(pt) end if any(testno == 5) lps = 10*loops; N = 30*n; clc; fprintf('TEST 5 - A+A (A small): %g loops\n', lps) tic; [time_sma,sd_sma] = ma(N, lps); t_f = toc; fprintf('TEST 5 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{5}.name = 'TEST 5'; times.test{5}.avg = time_sma; times.test{5}.sd = sd_sma; times.test{5}.tot = t_f; pause(pt) end if any(testno == 6) lps = 10*loops; N = 100*n; clc; fprintf('TEST 6 - A+A (A large): %g loops', lps) tic; [time_lma,sd_lma] = ma(N, lps); t_f = toc; fprintf('TEST 6 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{6}.name = 'TEST 6'; times.test{6}.avg = time_lma; times.test{6}.sd = sd_lma; times.test{6}.tot = t_f; pause(pt) end if any(testno == 7) lps = 10*loops; N = 30*n; clc; fprintf('TEST 7 - A*A (A small, real): %g loops', lps) tic; [time_srmm,sd_srmm] = rmm(N,lps); t_f = toc; fprintf('TEST 7 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{7}.name = 'TEST 7'; times.test{7}.avg = time_srmm; times.test{7}.sd = sd_srmm; times.test{7}.tot = t_f; pause(pt) end if any(testno == 8) lps = loops; N = 100*n; clc; fprintf('TEST 8 - A*A (A large, real): %g loops', lps) tic; [time_lrmm,sd_lrmm] = rmm(N, lps); t_f = toc; fprintf('TEST 8 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{8}.name = 'TEST 8'; times.test{8}.avg = time_lrmm; times.test{8}.sd = sd_lrmm; times.test{8}.tot = t_f; pause(pt) end if any(testno == 9) lps = 10*loops; N = 30*n; clc; fprintf('TEST 9 - A*A (A small, complex): %g loops', lps) tic; [time_scmm,sd_scmm] = cmm(N, lps); t_f = toc; fprintf('TEST 9 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{9}.name = 'TEST 9'; times.test{9}.avg = time_scmm; times.test{9}.sd = sd_scmm; times.test{9}.tot = t_f; pause(pt) end if any(testno == 10) lps = loops; N = 100*n; clc; fprintf('TEST 10 - A*A (A large, complex): %g loops', lps) tic; [time_lcmm,sd_lcmm] = cmm(N, lps); t_f = toc; fprintf('TEST 10 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{10}.name = 'TEST 10'; times.test{10}.avg = time_lcmm; times.test{10}.sd = sd_lcmm; times.test{10}.tot = t_f; pause(pt) end if any(testno == 11) lps = loops; N = 100*n; clc; fprintf('TEST 11 - log(A) (A complex): %g loops', lps) tic; [time_lgm,sd_lgm] = lgm(N, lps); t_f = toc; fprintf('TEST 11 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{11}.name = 'TEST 11'; times.test{11}.avg = time_lgm; times.test{11}.sd = sd_lgm; times.test{11}.tot = t_f; pause(pt) end if any(testno == 12) lps = loops; N = 100*n; clc; fprintf('TEST 12 - Gamma(A) (A real): %g loops', lps) tic; [time_gm,sd_gm] = gm(N, lps); t_f = toc; fprintf('TEST 12 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{12}.name = 'TEST 12'; times.test{12}.avg = time_gm; times.test{12}.sd = sd_gm; times.test{12}.tot = t_f; pause(pt) end if any(testno == 13) lps = loops; N = 50000*n; clc; fprintf('TEST 13 - vector sorting: %g loops', lps) tic; [time_vs,sd_vs] = vs(N, lps); t_f = toc; fprintf('TEST 13 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{13}.name = 'TEST 13'; times.test{13}.avg = time_vs; times.test{13}.sd = sd_vs; times.test{13}.tot = t_f; pause(pt) end if any(testno == 14) lps = 10*loops; N = 2*n; clc; fprintf('TEST 14 - multidimensional matrix sorting: %g loops', lps) tic; [time_mms,sd_mms] = mms(N, lps); t_f = toc; fprintf('TEST 14 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{14}.name = 'TEST 14'; times.test{14}.avg = time_mms; times.test{14}.sd = sd_mms; times.test{14}.tot = t_f; pause(pt) end if any(testno == 15) lps = loops; N = 30*n; clc; fprintf('TEST 15 - inv(A) (A small, complex): %g loops', lps) tic; [time_smi,sd_smi] = mi(N, lps); t_f = toc; fprintf('TEST 15 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{15}.name = 'TEST 15'; times.test{15}.avg = time_smi; times.test{15}.sd = sd_smi; times.test{15}.tot = t_f; pause(pt) end if any(testno == 16) lps = loops; N = 50*n; clc; fprintf('TEST 16 - inv(A) (A large, complex): %g loops', lps) tic; [time_lmi,sd_lmi] = mi(N, lps); t_f = toc; fprintf('TEST 16 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{16}.name = 'TEST 16'; times.test{16}.avg = time_lmi; times.test{16}.sd = sd_lmi; times.test{16}.tot = t_f; pause(pt) end if any(testno == 17) lps = loops; N = 30*n; clc; fprintf('TEST 17 - lu(A) (A small, complex): %g loops', lps) tic; [time_sluf,sd_sluf] = luf(N, lps); t_f = toc; fprintf('TEST 17 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{17}.name = 'TEST 17'; times.test{17}.avg = time_sluf; times.test{17}.sd = sd_sluf; times.test{17}.tot = t_f; pause(pt) end if any(testno == 18) lps = loops; N = 50*n; clc; fprintf('TEST 18 - lu(A) (A large, complex): %g loops', lps) tic; [time_lluf,sd_lluf] = luf(N, lps); t_f = toc; fprintf('TEST 18 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{18}.name = 'TEST 18'; times.test{18}.avg = time_lluf; times.test{18}.sd = sd_lluf; times.test{18}.tot = t_f; pause(pt) end if any(testno == 19) lps = loops; N = 20*n; clc; fprintf('TEST 19 - eig(A) (A small, complex, eigenvalues only): %g loops', lps) tic; [time_seigv,sd_seigv] = eigv(N, lps, 0); t_f = toc; fprintf('TEST 19 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{19}.name = 'TEST 19'; times.test{19}.avg = time_seigv; times.test{19}.sd = sd_seigv; times.test{19}.tot = t_f; pause(pt) end if any(testno == 20) lps = loops/10; N = 50*n; clc; fprintf('TEST 20 - eig(A) (A large, complex, eigenvalues only): %g loops', lps) tic; [time_leigv,sd_leigv] = eigv(N, lps, 0); t_f = toc; fprintf('TEST 20 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{20}.name = 'TEST 20'; times.test{20}.avg = time_leigv; times.test{20}.sd = sd_leigv; times.test{20}.tot = t_f; pause(pt) end if any(testno == 21) lps = loops; N = 20*n; clc; fprintf('TEST 21 - eig(A) (A small, complex): %g loops', lps) tic; [time_seigvv,sd_seigvv] = eigv(N, lps, 1); t_f = toc; fprintf('TEST 21 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{21}.name = 'TEST 21'; times.test{21}.avg = time_seigvv; times.test{21}.sd = sd_seigvv; times.test{21}.tot = t_f; pause(pt) end if any(testno == 22) lps = loops/10; N = 50*n; clc; fprintf('TEST 22 - eig(A) (A large, complex): %g loops', lps) tic; [time_leigvv,sd_leigvv] = eigv(N, lps, 1); t_f = toc; fprintf('TEST 22 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{22}.name = 'TEST 22'; times.test{22}.avg = time_leigvv; times.test{22}.sd = sd_leigvv; times.test{22}.tot = t_f; pause(pt) end if any(testno == 23) lps = 10*loops; N = 100000*n; clc; fprintf('TEST 23 - sparse matrix generator: %g loops', lps) tic; [time_smg,sd_smg] = smg(N, lps); t_f = toc; fprintf('TEST 23 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{23}.name = 'TEST 23'; times.test{23}.avg = time_smg; times.test{23}.sd = sd_smg; times.test{23}.tot = t_f; pause(pt) end if any(testno == 24) lps = loops; N = 7000*n; clc; fprintf('TEST 24 - sparse lu (A complex, banded): %g loops', lps) tic; [time_slu,sd_slu] = slu(N, lps); t_f = toc; fprintf('TEST 24 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{24}.name = 'TEST 24'; times.test{24}.avg = time_slu; times.test{24}.sd = sd_slu; times.test{24}.tot = t_f; pause(pt) end if any(testno == 25) lps = loops; clc; fprintf('TEST 25 - eigs(A): %g loops', lps) tic; [time_seig,sd_seig] = seig(lps); t_f = toc; fprintf('TEST 25 - finished in %g seconds\n', t_f); t_0 = t_0 + t_f; times.test{25}.name = 'TEST 25'; times.test{25}.avg = time_seig; times.test{25}.sd = sd_seig; times.test{25}.tot = t_f; pause(pt) end times.totalflops = flops; times.mbenchtotal = t_0; times.megabogoflops = (flops/t_0)/10^6; clc disp('== MBENCH RESULTS ==') disp('All results in seconds') times.test{testno} fprintf('mbench: total time to complete the test (seconds): %g\n', t_0) fprintf('mbench: total number of megaflops: %g\n', times.totalflops/10^6) if (nargin == 0 & n == 12) disp('Comparison with other machines (MegabogoFLOPS)') disp('MATLAB 5.3, 2 194MHZ R10K, 256Mb RAM, IRIX64 v6.5: 100.877') % Full specs % Version: MATLAB 5.3.0.10183 (R11) % OS: IRIX64 6.5 01221553 IP25 mips % Computer Model: SGI Challenge % Processors: 2 194 MHZ MIPS 10000 IP25 Processors % Main memory size: 256 Mbytes, 2-way interleaved % Instruction cache size: 32 Kbytes % Data cache size: 32 Kbytes % Secondary unified instruction/data cache size: 1 Mbyte % Comments: The benchmark ran by itself overnight (no % other major processes). Some tests used both % CPUs. fprintf('Your machine: %g\n', times.megabogoflops) end disp('mbench done!') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % nested FOR loops (nfl) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = nfl(n,loops) time = zeros(1,loops); t_i = cputime; for ii = 1:loops for jj = 1:loops for kk = 1:loops for ll = 1:loops A = 1; end end end home; fprintf('\n%g\n', ii) end t_f = cputime - t_i; sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % random matrix generator (rmg) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = rmg(n,loops) time = zeros(1,loops); for ii = 1:loops t_i = cputime; randn(n,n); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fft (ffta) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = ffta(n,loops) time = zeros(1,loops); for ii = 1:loops A = randn(n,1); t_i = cputime; fft(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % matrix addition (ma) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = ma(n,loops) time = zeros(1,loops); for ii = 1:loops A = randn(n); t_i = cputime; A+A; t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % real matrix multiplication (rmm) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = rmm(n,loops) time = zeros(1,loops); for ii = 1:loops A = randn(n); t_i = cputime; A*A; t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % complex matrix multiplication (cmm) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = cmm(n,loops) i = sqrt(-1); time = zeros(1,loops); for ii = 1:loops A = randn(n) + i*randn(n); t_i = cputime; A*A; t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % log(A), A complex (lgm) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = lgm(n,loops) time = zeros(1,loops); for ii = 1:loops A = randn(n) + i*randn(n); t_i = cputime; log(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Gamma(A), A real (gm) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = gm(n,loops) time = zeros(1,loops); for ii = 1:loops A = rand(n); t_i = cputime; gamma(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % vector sorting (vs) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = vs(n,loops) time = zeros(1,loops); A = randn(n,1); for ii = 1:loops t_i = cputime; sort(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % multidimensional matrix sorting (mms) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = mms(n,loops) time = zeros(1,loops); A = rand(n,n,n,n); for ii = 1:loops t_i = cputime; sort(A,1);sort(A,2);sort(A,3);sort(A,4);t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % matrix inversion (mi) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = mi(n,loops) time = zeros(1,loops); i = sqrt(-1); for ii = 1:loops A = rand(n) + i*rand(n); t_i = cputime; inv(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % lu factorization (luf) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = luf(n,loops) time = zeros(1,loops); i = sqrt(-1); for ii = 1:loops A = rand(n) + i*rand(n); t_i = cputime; [L,U,P] = lu(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % eigenvalues (eigv) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = eigv(n,loops,vec) time = zeros(1,loops); i = sqrt(-1); for ii = 1:loops A = rand(n) + i*rand(n); if (vec == 1) t_i = cputime; [V1,V2] = eig(A); t_f = cputime - t_i; else t_i = cputime; eig(A); t_f = cputime - t_i; end time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % sparse matrix generator (smg) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = smg(n,loops) time = zeros(1,loops); for ii = 1:loops t_i = cputime; sprandn(n,n,1/(100*n)); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % sparse lu (slu) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = slu(n,loops) time = zeros(1,loops); i = sqrt(-1); for ii = 1:loops A = spdiags(rand(n,5) + i*rand(n,5),[-2:2],n,n); t_i = cputime; [L,U] = lu(A); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % sparse eigenvalues (seig) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [time,sd] = seig(loops) time = zeros(1,loops); load west0479; options.disp = 0; for ii = 1:loops t_i = cputime; eigs(west0479,8,options); t_f = cputime - t_i; time(ii) = t_f; home; fprintf('\n%g\n', ii) end sd = std(time)/sqrt(length(time)); time = mean(time);