Test the efficiency of polynomial computing and the efficiency of polynomial computing. The efficiency test of polynomial computing, the polynomial computing efficiency, the pow method of the library function called by the polynomial computing, and the Qin Jiuyun algorithm are used to calculate the operating efficiency of the computing functions f (x) 1 + (xii) test the efficiency of polynomial computing and the efficiency of polynomial computing
The pow method and the qinjiu algorithm of polynomial computing call library function are used to calculate their operation efficiency.
Calculation function f (x) = 1 + (Σ xi/I) (I get from 1 to m );
Use the ctime function to test the running time, which is calculated by x = 0.9.
# Include
# Include ;
# Include
Using namespace std;
Double Fn1 (double x );
Double Fn2 (double x );
# Define m 1000000000
Clock_t start, stop;
Int main (){
Double x;
X = 0.9;
Start = clock ();
Cout <Fn1 (x) <endl;
Stop = clock ();
Cout <double (stop-start)/CLK_TCK <endl;
//-----------------------------------
Start = clock ();
Cout <Fn2 (x) <endl;
Stop = clock ();
Cout <double (stop-start)/CLK_TCK <endl;
Return 0;
}
Double Fn1 (double x ){
Int I;
Double f = 1.0;
For (I = 1; I <= m; I ++)
F + = pow (x, I)/I;
Return f;
}
Double Fn2 (double x ){
Int I;
Double f = 0.0;
For (I = m; I> = 1; I --)/* qinjiu polynomial algorithm */
F = f * x + 1.0/I;
Return f * x + 1.0;
}
For the running time, see the following table.
M |
100 |
1000 |
10000 |
100000 |
1000000 |
10000000 |
1000000 |
1000000000 |
Fn1 |
0.001 |
0.001 |
0.003 |
0.015 |
0.157 |
1.619 |
17.955 |
191.608 |
Fn2 |
0 |
0 |
0 |
0.001 |
0.005 |
0.049 |
0.472 |
4.706 |
According to the running time, the efficiency of the qinjiu algorithm is much higher than that of the pow method.
Polynomial computing calls the database function pow method and the Qin Jiuyun algorithm. let's calculate their operation efficiency. the computing function f (x) = 1 + (x I/I )...