MATLAB Functions | Help Desk |
flops
Count floating-point operations
f = flops flops(0)
f = flops
returns the cumulative number of floating-point operations.
flops(0)
resets the count to zero.
If A
and B
are real n
-by-n
matrices, some typical flop counts for different operations are
|
---|
n = 100; A = rand(n,n); b = rand(n,1); flops(0) tic; x = A\b; t = toc megaflops = flops/t/1.e6It is not feasible to count all the floating-point operations, but most of the important ones are counted. Additions and subtractions are each one flop if real and two if complex. Multiplications and divisions count one flop each if the result is real and six flops if it is complex. Elementary functions count one if real and more if complex.