3 #ifndef __rmsAccumulator_h__
4 #define __rmsAccumulator_h__
10 template<
class floatT>
14 std::vector<std::vector<floatT> > values;
15 std::vector<floatT> means;
16 std::vector<floatT> rmss;
21 void resize(
int nstr,
int len);
28 void addValues(std::vector<floatT> newVals);
31 void addValues(floatT * newVals);
39 template<
typename floatT>
45 values.resize(length);
47 for(
int i=0;i<length; ++i)
49 values[i].resize(nStreams, 0);
52 means.resize(nStreams,0);
53 rmss.resize(nStreams,0);
59 template<
typename floatT>
62 if(newVals.size() != values[0].size())
64 std::cerr <<
"wrong size\n";
68 values[currVal] = newVals;
72 if(currVal >= values.size()) currVal = 0;
76 template<
typename floatT>
79 for(
int i=0;i<nStreams;++i)
80 values[currVal][i] = newVals[i];
84 if(currVal >= values.size()) currVal = 0;
88 template<
typename floatT>
91 for(
int i=0;i<nStreams;++i)
93 means[i] = values[currVal][i]/length;
97 if(j >= length) j = 0;
100 for(
int i=0;i<nStreams;++i)
102 means[i] += values[j][i]/length;
105 if(j >= length) j = 0;
109 template<
typename floatT>
113 for(
int i=0;i<nStreams;++i)
115 d = values[currVal][i];
117 rmss[i] = (d*d)/length;
123 if(j >= length) j = 0;
127 for(
int i=0;i<nStreams;++i)
131 rmss[i] += (d*d)/length;
134 if(j >= length) j = 0;
138 #endif //__rmsAccumulator_h__