Internal function to calculate the different scalability forms
| 27 | |
| 28 | // Internal function to calculate the different scalability forms |
| 29 | BigOFunc* FittingCurve(BigO complexity) { |
| 30 | static const double kLog2E = 1.44269504088896340736; |
| 31 | switch (complexity) { |
| 32 | case oN: |
| 33 | return [](IterationCount n) -> double { return static_cast<double>(n); }; |
| 34 | case oNSquared: |
| 35 | return [](IterationCount n) -> double { return std::pow(n, 2); }; |
| 36 | case oNCubed: |
| 37 | return [](IterationCount n) -> double { return std::pow(n, 3); }; |
| 38 | case oLogN: |
| 39 | /* Note: can't use log2 because Android's GNU STL lacks it */ |
| 40 | return |
| 41 | [](IterationCount n) { return kLog2E * log(static_cast<double>(n)); }; |
| 42 | case oNLogN: |
| 43 | /* Note: can't use log2 because Android's GNU STL lacks it */ |
| 44 | return [](IterationCount n) { |
| 45 | return kLog2E * n * log(static_cast<double>(n)); |
| 46 | }; |
| 47 | case o1: |
| 48 | default: |
| 49 | return [](IterationCount) { return 1.0; }; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // Function to return an string for the calculated complexity |
| 54 | std::string GetBigOString(BigO complexity) { |