24 #include "cheetah/utils/BinMap.h" 25 #pragma GCC diagnostic push 26 #pragma GCC diagnostic ignored "-Wall" 27 #pragma GCC diagnostic ignored "-Wpragmas" 28 #pragma GCC diagnostic ignored "-Wunused-parameter" 29 #pragma GCC diagnostic ignored "-Wunused-variable" 30 #include <boost/units/quantity.hpp> 31 #pragma GCC diagnostic pop 39 template<
typename DataType>
43 DataType operator()(DataType
const& data, T
const& t)
const {
48 DataType divide(DataType
const& data, T
const& t)
const {
49 return data/DataType(t);
53 template<
typename Unit,
typename DataType>
57 boost::units::quantity<Unit,DataType> operator()(boost::units::quantity<Unit,DataType>
const& data, T
const& t)
const {
58 return data *
static_cast<DataType
>(t);
62 boost::units::quantity<Unit,DataType> divide(boost::units::quantity<Unit,DataType>
const& data, T
const& t)
const {
63 return data/
static_cast<DataType
>(t);
69 template<
typename DataType>
77 template<
typename DataType>
82 template<
typename DataType>
84 : _n_bins(number_of_bins)
90 template<
typename DataType>
92 : _n_bins(number_of_bins)
93 , _lower(
std::move(start))
98 template<
typename DataType>
104 template<
typename DataType>
111 template<
typename DataType>
115 set_upper_bound(upper);
118 template<
typename DataType>
124 template<
typename DataType>
130 template<
typename DataType>
136 template<
typename DataType>
139 return last_bin_assignment_value() + _halfwidth;
142 template<
typename DataType>
148 template<
typename DataType>
151 return bin_assignment_number(index) - _halfwidth;
154 template<
typename DataType>
157 return bin_assignment_number(index) + _halfwidth;
160 template<
typename DataType>
163 return (
int)(0.5 + ((value - _lower)/ _width ));
166 template<
typename DataType>
172 template<
typename DataType>
178 template<
typename DataType>
181 return _lower + _halfwidth;
184 template<
typename DataType>
190 template<
typename DataType>
196 template<
typename DataType>
199 return map._lower == _lower && map._n_bins == _n_bins && map._width == _width;
202 template<
typename DataType>
205 return map_1.equal(map_2);
214 template<
typename DataType>
215 struct hash<
ska::cheetah::utils::BinMap<DataType>> {
217 return std::hash<unsigned>()(map.
number_of_bins()) ^ std::hash<DataType>()(map.lower_bound()) ^ (std::hash<DataType>()(map.
bin_width()) << 4);
unsigned int bin_index(DataType const &) const
give the bin Index of the value. n.b no range checks are made so passing endValue() will return an i...
Explicitly map a range on to a set of constant width indexed data bins.
Some limits and constants for FLDO.
void reset(unsigned int number_of_bins)
reset the number of bins
void set_bin_width(DataType)
set the width of each bin
void set_lower_bound(DataType)
set the assignemnt value for the first bin (n.b. not the same as the lower limit of the first bin) ...
unsigned int number_of_bins() const
the total number of bins
DataType bin_width() const
the width of a the bin (all are the same width)
void set_bounds(DataType lower, DataType upper)
set the the lower bound for first bin