if 0 % run under matlab 5 a = rand(2,3); b = rand(3,4); c = rand(3); flops(0); a+a; flops flops(0); a.*a; flops flops(0); a./a; flops flops(0); ab; end; t=toc/niter; fprintf('time for >: %g\tflops = %g (should be %g)\n', t, t/t_arith, 2); %tic; for i=1:niter a==b; end; t=toc/niter; tic; for i=1:niter a~=b; end; t=toc/niter; fprintf('time for ~=: %g\tflops = %g\n', t, t/t_arith); end if 0 tic; for i=1:niter randn(100); end; t=toc/niter; t = t-t_ones; fprintf('time for randn: %g\tflops = %g\n', t, t/t_arith); end if 0 tic; for i=1:niter a.^(0.51); end; t=toc/niter; e1 = exp(1); tic; for i=1:niter e1.^a; end; t=toc/niter; t = t-t_ones; fprintf('time for pow: %g\tflops = %g\n', t, t/t_arith); if 0 tic; for i=1:niter a.^(0.5); end; toc tic; for i=1:niter sqrt(a); end; toc end end tic; for i=1:niter sqrt(a); end; t_sqrt=toc/niter; fprintf('time for sqrt: %g\tflops = %g (should be %g)\n', t_sqrt, t_sqrt/t_arith, flops_sqrt); tic; for i=1:niter exp(a); end; t_exp=toc/niter; fprintf('time for exp: %g\tflops = %g (should be %g)\n', t_exp, t_exp/t_arith, flops_exp); tic; for i=1:niter pow2(a); end; t_pow2=toc/niter; fprintf('time for pow2: %g\tflops = %g (should be %g)\n', t_pow2, t_pow2/t_arith, flops_exp); tic; for i=1:niter log(a); end; t_log=toc/niter; fprintf('time for log: %g\tflops = %g (should be %g)\n', t_log, t_log/t_arith, flops_log); tic; for i=1:niter log2(a); end; t_log=toc/niter; fprintf('time for log2: %g\tflops = %g (should be %g)\n', t_log, t_log/t_arith, flops_log);