1 | #include <iostream> |
---|
2 | #include <Utils/Statistics.hh> |
---|
3 | #include <Utils/utils.hh> |
---|
4 | |
---|
5 | namespace Statistics |
---|
6 | { |
---|
7 | template StatsContainer<int>; |
---|
8 | template StatsContainer<long>; |
---|
9 | template StatsContainer<float>; |
---|
10 | template StatsContainer<double>; |
---|
11 | //-------------------------------------------------------------------- |
---|
12 | //-------------------------------------------------------------------- |
---|
13 | |
---|
14 | template <class Type> |
---|
15 | StatsContainer<Type>::StatsContainer(const StatsContainer<Type>& s) |
---|
16 | { |
---|
17 | this->defined = s.defined; |
---|
18 | this->mean = s.mean; |
---|
19 | this->stddev = s.stddev; |
---|
20 | this->median = s.median; |
---|
21 | this->madfm = s.madfm; |
---|
22 | this->threshold = s.threshold; |
---|
23 | this->pThreshold = s.pThreshold; |
---|
24 | this->useRobust = s.useRobust; |
---|
25 | this->useFDR = s.useFDR; |
---|
26 | } |
---|
27 | template StatsContainer<int>::StatsContainer(const StatsContainer<int>& s); |
---|
28 | template StatsContainer<long>::StatsContainer(const StatsContainer<long>& s); |
---|
29 | template StatsContainer<float>::StatsContainer(const StatsContainer<float>& s); |
---|
30 | template StatsContainer<double>::StatsContainer(const StatsContainer<double>& s); |
---|
31 | //-------------------------------------------------------------------- |
---|
32 | |
---|
33 | template <class Type> |
---|
34 | StatsContainer<Type>& StatsContainer<Type>::operator= (const StatsContainer<Type>& s) |
---|
35 | { |
---|
36 | this->defined = s.defined; |
---|
37 | this->mean = s.mean; |
---|
38 | this->stddev = s.stddev; |
---|
39 | this->median = s.median; |
---|
40 | this->madfm = s.madfm; |
---|
41 | this->threshold = s.threshold; |
---|
42 | this->pThreshold = s.pThreshold; |
---|
43 | this->useRobust = s.useRobust; |
---|
44 | this->useFDR = s.useFDR; |
---|
45 | } |
---|
46 | template StatsContainer<int>& StatsContainer<int>::operator= (const StatsContainer<int>& s); |
---|
47 | template StatsContainer<long>& StatsContainer<long>::operator= (const StatsContainer<long>& s); |
---|
48 | template StatsContainer<float>& StatsContainer<float>::operator= (const StatsContainer<float>& s); |
---|
49 | template StatsContainer<double>& StatsContainer<double>::operator= (const StatsContainer<double>& s); |
---|
50 | //-------------------------------------------------------------------- |
---|
51 | |
---|
52 | template <class Type> |
---|
53 | void StatsContainer<Type>::calculate(Type *array, long size) |
---|
54 | { |
---|
55 | /** |
---|
56 | * Calculate all four statistics for all elements of a given |
---|
57 | * array. |
---|
58 | * |
---|
59 | * \param array The input data array. |
---|
60 | * \param size The length of the input array |
---|
61 | */ |
---|
62 | findNormalStats(array, size, this->mean, this->stddev); |
---|
63 | findMedianStats(array, size, this->median, this->madfm); |
---|
64 | this->defined = true; |
---|
65 | } |
---|
66 | template void StatsContainer<int>::calculate(int *array, long size); |
---|
67 | template void StatsContainer<long>::calculate(long *array, long size); |
---|
68 | template void StatsContainer<float>::calculate(float *array, long size); |
---|
69 | template void StatsContainer<double>::calculate(double *array, long size); |
---|
70 | //-------------------------------------------------------------------- |
---|
71 | |
---|
72 | template <class Type> |
---|
73 | void StatsContainer<Type>::calculate(Type *array, long size, bool *isGood) |
---|
74 | { |
---|
75 | /** |
---|
76 | * Calculate all four statistics for a subset of a given |
---|
77 | * array. The subset is defined by an array of bool |
---|
78 | * variables. |
---|
79 | * |
---|
80 | * \param array The input data array. |
---|
81 | * \param size The length of the input array |
---|
82 | * \param isGood An array of the same length that says whether to |
---|
83 | * include each member of the array in the calculations. |
---|
84 | */ |
---|
85 | findNormalStats(array, size, isGood, this->mean, this->stddev); |
---|
86 | findMedianStats(array, size, isGood, this->median, this->madfm); |
---|
87 | this->defined = true; |
---|
88 | } |
---|
89 | template void StatsContainer<int>::calculate(int *array, long size, bool *isGood); |
---|
90 | template void StatsContainer<long>::calculate(long *array, long size, bool *isGood); |
---|
91 | template void StatsContainer<float>::calculate(float *array, long size, bool *isGood); |
---|
92 | template void StatsContainer<double>::calculate(double *array, long size, bool *isGood); |
---|
93 | //-------------------------------------------------------------------- |
---|
94 | |
---|
95 | template <class Type> |
---|
96 | std::ostream& operator<< (std::ostream& theStream, StatsContainer<Type> &s) |
---|
97 | { |
---|
98 | /** |
---|
99 | * Prints out the four key statistics to the requested stream. |
---|
100 | */ |
---|
101 | theStream << "Mean = " << s.mean << "\t" |
---|
102 | << "Std.Dev. = " << s.stddev << "\n" |
---|
103 | << "Median = " << s.median << "\t" |
---|
104 | << "MADFM = " << s.madfm << "\n"; |
---|
105 | } |
---|
106 | template std::ostream& operator<<<int> (std::ostream& theStream, StatsContainer<int> &s); |
---|
107 | template std::ostream& operator<<<long> (std::ostream& theStream, StatsContainer<long> &s); |
---|
108 | template std::ostream& operator<<<float> (std::ostream& theStream, StatsContainer<float> &s); |
---|
109 | template std::ostream& operator<<<double> (std::ostream& theStream, StatsContainer<double> &s); |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | } // matches: namespace Statistics { |
---|