/* * StatisticData.hh * * Created on: Nov 08, 2014 * Author: AKKA */ #ifndef STATISTICDATA_HH_ #define STATISTICDATA_HH_ #include <vector> namespace AMDA { namespace Parameters { template<typename Type> struct StatisticDataScalar { Type _result; int _nbDataProcessed; }; template<typename Type> using StatisticDataVector = std::vector<StatisticDataScalar<Type>>; template<typename Type> using StatisticDataMatrix = std::vector<std::vector<StatisticDataScalar<Type>>> ; template<typename Type> void pushStatisticDataInVectorString(std::vector<std::string> &result, std::vector<std::string> &coverage, StatisticDataScalar<Type> data, int ideal, bool isCoverageIndependantOfResultType, int /* index */) { //push result std::stringstream res; res << data._result; result.push_back(res.str()); //push coverage if (isCoverageIndependantOfResultType && (coverage.size() >= 1)) return; double c = (double)data._nbDataProcessed / ((double)ideal+1); if (c < 0.) c = 0.; if (c > 1.) c = 1.; std::stringstream cov; cov << c; coverage.push_back(cov.str()); } template<typename Type> void pushStatisticDataInVectorString(std::vector<std::string> &result, std::vector<std::string> &coverage, StatisticDataVector<Type> data, int ideal, bool isCoverageIndependantOfResultType, int index) { for (int i = 0; i < (int)data.size(); ++i) { if ((index >= 0) && (index != (int)i)) continue; pushStatisticDataInVectorString(result, coverage, data[i], ideal, isCoverageIndependantOfResultType, -1); } } template<typename Type> void pushStatisticDataInVectorString(std::vector<std::string> &result, std::vector<std::string> &coverage, StatisticDataMatrix<Type> data, int ideal, bool isCoverageIndependantOfResultType, int index) { for (int i = 0; i < (int)data.size(); ++i) { for (int j = 0; j < (int)data[i].size(); ++j) { if ((index >= 0) && (index != i*(int)data.size()+j)) continue; pushStatisticDataInVectorString(result, coverage, data[i][j], ideal, isCoverageIndependantOfResultType, -1); } } } } /* namespace Parameters */ } /* namespace AMDA */ #endif