From 37ab858e4b245a49805b01358655fab069474a7c Mon Sep 17 00:00:00 2001 From: Ismael Date: Thu, 26 May 2016 19:44:11 +0200 Subject: [PATCH] initialized doubles to 0.0 --- include/benchmark/complexity.h | 12 ++++++------ src/complexity.cc | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/benchmark/complexity.h b/include/benchmark/complexity.h index f2eaefa6..76318d8b 100644 --- a/include/benchmark/complexity.h +++ b/include/benchmark/complexity.h @@ -48,23 +48,23 @@ enum BigO { struct LeastSq { LeastSq() : - coef(0), - rms(0), - complexity(benchmark::oNone) {} + coef(0.0), + rms(0.0), + complexity(oNone) {} double coef; double rms; - benchmark::BigO complexity; + BigO complexity; }; // Function to return an string for the calculated complexity -std::string GetBigOString(benchmark::BigO complexity); +std::string GetBigOString(BigO complexity); // Find the coefficient for the high-order term in the running time, by // minimizing the sum of squares of relative error. LeastSq MinimalLeastSq(const std::vector& n, const std::vector& time, - const benchmark::BigO complexity = benchmark::oAuto); + const BigO complexity = oAuto); } // end namespace benchmark #endif // COMPLEXITY_H_ diff --git a/src/complexity.cc b/src/complexity.cc index 8fa75b37..e7233109 100644 --- a/src/complexity.cc +++ b/src/complexity.cc @@ -86,10 +86,10 @@ std::string GetBigOString(BigO complexity) { LeastSq CalculateLeastSq(const std::vector& n, const std::vector& time, std::function fitting_curve) { - double sigma_gn = 0; - double sigma_gn_squared = 0; - double sigma_time = 0; - double sigma_time_gn = 0; + double sigma_gn = 0.0; + double sigma_gn_squared = 0.0; + double sigma_time = 0.0; + double sigma_time_gn = 0.0; // Calculate least square fitting parameter for (size_t i = 0; i < n.size(); ++i) { @@ -106,7 +106,7 @@ LeastSq CalculateLeastSq(const std::vector& n, result.coef = sigma_time_gn / sigma_gn_squared; // Calculate RMS - double rms = 0; + double rms = 0.0; for (size_t i = 0; i < n.size(); ++i) { double fit = result.coef * fitting_curve(n[i]); rms += pow((time[i] - fit), 2);