18 #include "../declspec.h"
55 typedef int size_type;
56 typedef StatisticData::count_type count_type;
59 HistogramBuilder(
const count_type* bins,
int nbins,
double min,
double max, count_type scnt,
double ssum,
double sssq,
double smin,
double smax);
73 template <
typename It>
void add(It begin, It end);
76 void scale(
double oldmin,
double oldmax,
double newmin,
double newmax);
80 template <
typename It>
void tryAdd(It begin, It end,
StatisticData *localstats);
81 template <
typename It>
void fastAddSignedChar256(It begin, It end);
92 template <
typename It>
93 void HistogramBuilder::fastAddSignedChar256(It begin, It end)
95 assert(this->gethisto().getsize() == 256 &&
96 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::is_integer &&
97 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::min()+128 == 0 &&
98 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::max() == +127 &&
99 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::min() == this->gethisto().getmin() &&
100 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::max() == this->gethisto().getmax());
103 for (It i = begin; i != end; ++i)
104 histo_.addToBinNumberUNSAFE(
static_cast<char>(*i) + 128);
114 stats_ =
StatisticData(gethisto().getbins(), gethisto().getsize(), gethisto().getmin(), gethisto().getmax(),
true);
122 template <
typename It>
123 void HistogramBuilder::add(It begin, It end)
131 if (std::numeric_limits<
typename std::iterator_traits<It>::value_type>::is_integer &&
132 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::min() == this->gethisto().getmin() &&
133 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::max() == this->gethisto().getmax())
135 if (this->gethisto().getsize() == 256 &&
136 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::min()+128 == 0 &&
137 std::numeric_limits<
typename std::iterator_traits<It>::value_type>::max() == +127)
140 fastAddSignedChar256(begin, end);
147 tryAdd<It>(begin, end, &tempstats);
155 template <
typename It>
156 void HistogramBuilder::tryAdd(It begin, It end,
StatisticData *localstats)
158 double combo_offset = 0, combo_scale = 1;
161 histo_.calculateConversionFactors(&combo_offset, &combo_scale);
185 std::int64_t cnt = 0;
186 std::int64_t inf = 0;
189 double min = std::numeric_limits<double>::max();
190 double max = -std::numeric_limits<double>::max();
192 for (It i = begin; i != end; ++i) {
193 register double value = *i;
196 if (std::numeric_limits<
typename std::iterator_traits<It>::value_type>::is_integer || std::isfinite(value)) {
198 int n = RoundD2I(combo_offset + combo_scale * value);
199 if (
static_cast<unsigned int>(n) <
static_cast<unsigned int>(gethisto().getsize()))
200 histo_.addToBinNumberUNSAFE(n);
215 if (localstats != NULL) {
216 *localstats = StatisticData(cnt, inf, sum, ssq, min, max);