25#ifndef ALEXANDRIA_HISTOGRAM_HISTOGRAM_H
26#define ALEXANDRIA_HISTOGRAM_HISTOGRAM_H
49template <
typename VarType>
123 return (edges.second + edges.first) / 2;
137template <
typename VarType,
typename WeightType =
float>
156 template <
typename IterType,
typename BinType,
158 Histogram(IterType begin, IterType end, BinType&& bin_type) {
159 auto binning_impl = make_unique<ComputationImpl<BinType>>(std::forward<BinType>(bin_type));
185 template <
typename IterType,
typename WeightIterType,
typename BinType,
187 Histogram(IterType begin, IterType end, WeightIterType wbegin, ELEMENTS_UNUSED WeightIterType wend,
188 BinType&& bin_type) {
189 assert(wend - wbegin == end - begin);
190 auto binning_impl = make_unique<ComputationImpl<BinType>>(std::forward<BinType>(bin_type));
191 binning_impl->computeBins(begin, end, wbegin);
251 std::generate(bins.
begin(), bins.
end(), [
this, &i]() { return m_binning_concept->getBinStrategy().getBin(i++); });
272 void clip(VarType min, VarType max) {
334 virtual void clip(VarType min, VarType max) = 0;
344 template <
typename BinType>
360 return make_unique<ComputationImpl<BinType>>(*this);
376 template <
typename IterType,
typename WeightIterType>
377 void computeBins(IterType begin, IterType end, WeightIterType wbegin);
379 void clip(VarType min, VarType max)
final;
390#include "Histogram/_impl/ComputationImpl.icpp"
virtual std::pair< VarType, VarType > getBinEdges(size_t i) const
virtual VarType getEdge(size_t e) const =0
virtual ssize_t getBinIndex(VarType value) const =0
virtual std::vector< VarType > getEdges() const
virtual VarType getBin(size_t i) const
virtual ~BinStrategy()=default
size_t getBinCount() const
std::vector< VarType > getEdges() const
Histogram(Histogram &&)=default
Histogram(IterType begin, IterType end, WeightIterType wbegin, ELEMENTS_UNUSED WeightIterType wend, BinType &&bin_type)
std::pair< VarType, VarType > getBinEdges(size_t i) const
void clip(VarType min, VarType max)
std::vector< VarType > getBins() const
std::unique_ptr< ComputationInterface > m_binning_concept
Histogram(IterType begin, IterType end, BinType &&bin_type)
Histogram & operator=(Histogram &&)=default
std::tuple< VarType, VarType, VarType > getStats() const
Histogram & operator=(const Histogram &)=default
Histogram(const Histogram &other)
std::vector< WeightType > getCounts() const
std::tuple< VarType, VarType, VarType > getStats() const final
std::unique_ptr< ComputationInterface > clone() const final
void computeBins(IterType begin, IterType end, WeightIterType wbegin)
const BinStrategy< VarType > & getBinStrategy() const final
void clip(VarType min, VarType max) final
ComputationImpl(BinType &&bin_type)
ComputationImpl(const ComputationImpl &)=default
virtual const BinStrategy< VarType > & getBinStrategy() const =0
std::shared_ptr< std::vector< WeightType > > m_counts
virtual std::tuple< VarType, VarType, VarType > getStats() const =0
virtual void clip(VarType min, VarType max)=0
virtual ~ComputationInterface()=default
virtual std::unique_ptr< ComputationInterface > clone() const =0
WeightType operator*() const
ConstantWeight & operator++()