25 #ifndef ALEXANDRIA_HISTOGRAM_HISTOGRAM_H
26 #define ALEXANDRIA_HISTOGRAM_HISTOGRAM_H
34 #include <type_traits>
48 template<
typename VarType>
79 virtual ssize_t
getBinIndex(VarType value)
const = 0;
109 virtual VarType
getEdge(
size_t e)
const = 0;
123 return (edges.second + edges.first) / 2;
137 template<
typename VarType,
typename WeightType =
float>
157 template<typename IterType, typename BinType, typename=typename std::enable_if<std::is_move_constructible<BinType>::value>::type>
158 Histogram(IterType begin, IterType end, BinType&& bin_type) {
159 auto binning_impl = make_unique<ComputationImpl<BinType>>(
std::move(bin_type));
185 template<typename IterType, typename WeightIterType, typename BinType, typename=typename std::enable_if<std::is_move_constructible<BinType>::value>::type>
186 Histogram(IterType begin, IterType end, WeightIterType wbegin, WeightIterType wend, BinType&& bin_type) {
187 assert(wend - wbegin == end - begin);
188 auto binning_impl = make_unique<ComputationImpl<BinType>>(
std::move(bin_type));
189 binning_impl->computeBins(begin, end, wbegin);
270 void clip(VarType min, VarType max) {
330 virtual void clip(VarType min, VarType max) = 0;
340 template<
typename BinType>
357 return make_unique<ComputationImpl<BinType>>(*this);
373 template<
typename IterType,
typename WeightIterType>
374 void computeBins(IterType begin, IterType end, WeightIterType wbegin);
376 void clip(VarType min, VarType max)
final;
387 #include "Histogram/_impl/ComputationImpl.icpp"
389 #endif // ALEXANDRIA_HISTOGRAM_HISTOGRAM_H
virtual std::vector< VarType > getEdges() const
std::pair< VarType, VarType > getBinEdges(size_t i) const
size_t getBinCount() const
virtual ~BinStrategy()=default
WeightType operator*() const
virtual std::tuple< VarType, VarType, VarType > getStats() const =0
virtual const BinStrategy< VarType > & getBinStrategy() const =0
virtual std::unique_ptr< ComputationInterface > clone() const =0
std::tuple< VarType, VarType, VarType > getStats() const final
virtual VarType getBin(size_t i) const
void clip(VarType min, VarType max) final
void clip(VarType min, VarType max)
ComputationImpl(BinType &&bin_type)
std::tuple< VarType, VarType, VarType > getStats() const
Histogram(IterType begin, IterType end, WeightIterType wbegin, WeightIterType wend, BinType &&bin_type)
std::vector< VarType > getEdges() const
virtual void clip(VarType min, VarType max)=0
std::unique_ptr< ComputationInterface > clone() const final
const BinStrategy< VarType > & getBinStrategy() const final
virtual VarType getEdge(size_t e) const =0
Histogram(IterType begin, IterType end, BinType &&bin_type)
virtual ssize_t getBinIndex(VarType value) const =0
ConstantWeight & operator++()
std::vector< VarType > getBins() const
void computeBins(IterType begin, IterType end, WeightIterType wbegin)
std::unique_ptr< ComputationInterface > m_binning_concept
std::shared_ptr< std::vector< WeightType > > m_counts
virtual std::pair< VarType, VarType > getBinEdges(size_t i) const
Histogram & operator=(const Histogram &)=default
Histogram(const Histogram &other)
std::vector< WeightType > getCounts() const