关于高版本的matlab中不再有查看浮点运算次数的函数flops,以及不再有相应的替代函数。这是为什么呢?
相关消息如下:
This is an obsolete function. Withthe incorporation of LAPACK in MATLAB version 6,
Remove all existing instances offlops. With the incorporation of LAPACK in MATLAB version 6,counting floa ting-point operations is no longerpractical.
相关资料显示:
%FLOPS Floatingpoint operation count.
% FLOPS returnsthe cumulative number of floating pointoperations.
%
% FLOPS(0) resetsthe count to zero.
%
% It is notfeasible to count absolutely all floating point
% operations, butmost of the important ones are counted.
% Additions andsubtractions are one flop if real and two if
% complex.Multiplications and divisions count one flopeach
% if the resultis real and six flops if it is not.
% Elementaryfunctions count one if real and more ifcomplex.
%
% Some examples.If A and B are real N-by-N matrices, then
% A + B countsN^2 flops,
% A * B counts2*N^3 flops,
% LU(A) countsroughly (2/3)*N^3 flops.
% A ^ P counts2*C*N^3 flops where, for integer P and
% D = DEC2BIN(P),C = length(D)+sum(D=='1')-1.
% Copyright (c)1984-98 by The MathWorks, Inc.
% $Revision: 5.6$ $Date: 1997/11/21 23:28:51 $
% Built-infunction.
这是5.3中的M文件中的内容
下载lightspeed工具包最新版
1.flops的值是可以估算的,和算法里面算O(n)之类的差不多。
2.圡办法:
自己搞个计数器,每有一次浮点表达式的时候就把这个计数器加n,n为表达式中浮点运
算的次数。
缺点1是圡,2是如果MATLAB对表达式优化的话(比如共同子表达式替换),这个计数值
和实际的flops会有出入。