Commit 5e52d2d6 by Ismael

refactor fitting curve

parent 5f9823bd
...@@ -20,19 +20,22 @@ ...@@ -20,19 +20,22 @@
#include <math.h> #include <math.h>
// Internal function to calculate the different scalability forms // Internal function to calculate the different scalability forms
double fittingCurve(double N, benchmark::BigO Complexity) { double fittingCurve(double n, benchmark::BigO complexity) {
if (Complexity == benchmark::O_N) switch (complexity) {
return N; case benchmark::O_N:
else if (Complexity == benchmark::O_N_Squared) return n;
return pow(N, 2); case benchmark::O_N_Squared:
else if (Complexity == benchmark::O_N_Cubed) return pow(n, 2);
return pow(N, 3); case benchmark::O_N_Cubed:
else if (Complexity == benchmark::O_log_N) return pow(n, 3);
return log2(N); case benchmark::O_log_N:
else if (Complexity == benchmark::O_N_log_N) return log2(n);
return N * log2(N); case benchmark::O_N_log_N:
return n * log2(n);
return 1; // Default value for O_1 case benchmark::O_1:
default:
return 1;
}
} }
// Internal function to find the coefficient for the high-order term in the running time, by minimizing the sum of squares of relative error. // Internal function to find the coefficient for the high-order term in the running time, by minimizing the sum of squares of relative error.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment