source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/test_flops2.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.4 KB
Line 
1% test flops for matrix operations
2
3niter = 50000;
4a = rand(100);
5a = a*a';
6T = chol(a);
7b = rand(100);
8c = rand(rows(a),1);
9
10t = [];
11tic; for i=1:niter a+4; end; t(1)=toc/niter;
12tic; for i=1:niter a+b; end; t(2)=toc/niter;
13tic; for i=1:niter a.*b; end; t(3)=toc/niter;
14t_arith = mean(t);
15%fprintf('average for +,*: %g\n', t_arith);
16t_flop = t_arith/prod(size(a));
17fprintf('time for 1 flop: %g\n', t_flop);
18
19tic; for i=1:niter solve_triu(T,c); end; t_solve_triu=toc/niter;
20fprintf('time for solve_triu: %g\tflops = %g (should be %d)\n', t_solve_triu, t_solve_triu/t_flop, flops_solve_tri(a,c));
21
22niter = niter/10;
23tic; for i=1:niter chol(a); end; t_chol=toc/niter;
24fprintf('time for chol: %g\tflops = %g (should be %d)\n', t_chol, t_chol/t_flop, flops_chol(rows(a)));
25
26tic; for i=1:niter det(a); end; t_det=toc/niter;
27fprintf('time for det: %g\tflops = %g (should be %d)\n', t_det, t_det/t_flop, flops_det(rows(a)));
28
29tic; for i=1:niter a\c; end; t_solve=toc/niter;
30fprintf('time for solve: %g\tflops = %g (should be %d)\n', t_solve, t_solve/t_flop, flops_solve(a,c));
31
32% matrix multiply is incredibly fast
33tic; for i=1:niter a*b; end; t_mtimes=toc/niter;
34fprintf('time for mtimes: %g\tflops = %g (should be %d)\n', t_mtimes, t_mtimes/t_flop, flops_mul(a,b));
35
36niter = niter/10;
37tic; for i=1:niter inv(a); end; t_inv=toc/niter;
38fprintf('time for inv: %g\tflops = %g (should be %d)\n', t_inv, t_inv/t_flop, flops_inv(rows(a)));
Note: See TracBrowser for help on using the repository browser.