61 for (uint32_t
i = 0;
i < bins;
i++) {
68 m_sumSquaredSamples = 0;
74 assert(m_binsize != -1);
75 uint32_t t_bins = m_data.size();
77 for (uint32_t
i = 0;
i < t_bins/2;
i++) {
78 m_data[
i] = m_data[
i*2] + m_data[
i*2 + 1];
80 for (uint32_t
i = t_bins/2;
i < t_bins;
i++) {
91 m_max = max(m_max, value);
94 m_sumSamples += value;
95 m_sumSquaredSamples += (value*value);
99 if (m_binsize == -1) {
105 if (
index >= m_data.size()) {
106 index = m_data.size() - 1;
111 uint32_t t_bins = m_data.size();
113 while (m_max >= (t_bins * m_binsize)) doubleBinSize();
114 index = value/m_binsize;
117 assert(
index < m_data.size());
119 m_largest_bin = max(m_largest_bin,
index);
125 uint32_t t_bins = m_data.size();
127 if (hist.
getBins() != t_bins) {
131 fatal(
"Histograms with different number of bins "
132 "cannot be combined!");
136 m_max = max(m_max, hist.
getMax());
137 m_count += hist.
size();
142 if (hist.
getBinSize() == -1 && m_binsize == -1) {
147 for (uint32_t
i = 1;
i < t_bins;
i++) {
152 }
else if (hist.
getBinSize() >= 1 && m_binsize >= 1) {
158 while (hist.
getBinSize() > m_binsize) doubleBinSize();
162 for (uint32_t
i = 0;
i < t_bins;
i++) {
165 if (m_data[
i] > 0) m_largest_bin =
i;
168 fatal(
"Don't know how to combine log and linear histograms!");
182 (double)(m_sumSquaredSamples - m_sumSamples * m_sumSamples / m_count)
184 return sqrt(variance);
190 printWithMultiplier(out, 1.0);
197 printWithMultiplier(out, 0.0);
199 printWithMultiplier(out, 100.0 /
double(m_count));
206 if (m_binsize == -1) {
207 out <<
"[binsize: log2 ";
209 out <<
"[binsize: " << m_binsize <<
" ";
211 out <<
"max: " << m_max <<
" ";
212 out <<
"count: " << m_count <<
" ";
215 out <<
"average: NaN |";
216 out <<
"standard deviation: NaN |";
218 out <<
"average: " << setw(5) << ((double) m_sumSamples)/m_count
220 out <<
"standard deviation: " << getStandardDeviation() <<
" |";
223 for (uint32_t
i = 0;
i <= m_largest_bin;
i++) {
224 if (multiplier == 1.0) {
225 out <<
" " << m_data[
i];
227 out <<
" " << double(m_data[
i]) * multiplier;