Blame view

src/Parameters/StatisticData.hh 2.13 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * 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;
	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