...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::histogram::axis::regular — Axis for equidistant intervals on the real line.
// In header: <boost/histogram/axis/regular.hpp> template<typename Value, typename Transform, typename MetaData, typename Options> class regular : public boost::histogram::axis::iterator_mixin< regular< Value, Transform, MetaData, Options > >, public metadata_base_t< MetaData > { public: // public member functions regular() = default; regular(transform_type, unsigned, value_type, value_type, metadata_type = {}, options_type = {}); explicit regular(unsigned, value_type, value_type, metadata_type = {}, options_type = {}); template<typename T> explicit regular(transform_type, step_type< T >, value_type, value_type, metadata_type = {}, options_type = {}); template<typename T> explicit regular(step_type< T >, value_type, value_type, metadata_type = {}, options_type = {}); regular(const regular &, index_type, index_type, unsigned); const transform_type & transform() const noexcept; index_type index(value_type) const noexcept; std::pair< index_type, index_type > update(value_type) noexcept; value_type value(real_index_type) const noexcept; decltype(auto) bin(index_type) const noexcept; index_type size() const noexcept; template<typename V, typename T, typename M, typename O> bool operator==(const regular< V, T, M, O > &) const noexcept; template<typename V, typename T, typename M, typename O> bool operator!=(const regular< V, T, M, O > &) const noexcept; template<typename Archive> void serialize(Archive &, unsigned); // public static functions static constexpr unsigned options() noexcept; };
The most common binning strategy. Very fast. Binning is a O(1) operation.
If the axis has an overflow bin (the default), a value on the upper edge of the last bin is put in the overflow bin. The axis range represents a semi-open interval.
If the overflow bin is deactivated, then a value on the upper edge of the last bin is still counted towards the last bin. The axis range represents a closed interval.
The options growth
andcircular
are mutually exclusive.
typename Value
input value type, must be floating point.
typename Transform
builtin or user-defined transform type.
typename MetaData
type to store meta data.
typename Options
see boost::histogram::axis::option.
regular
public member functionsregular() = default;
regular(transform_type trans, unsigned n, value_type start, value_type stop, metadata_type meta = {}, options_type options = {});Construct n bins over real transformed range [start, stop).
The constructor throws std::invalid_argument
if n is zero, or if start and stop produce an invalid range after transformation.
The arguments meta and alloc are passed by value. If you move either of them into the axis and the constructor throws, their values are lost. Do not move if you cannot guarantee that the bin description is not valid.
Parameters: |
|
explicit regular(unsigned n, value_type start, value_type stop, metadata_type meta = {}, options_type options = {});Construct n bins over real range [start, stop).
Parameters: |
|
template<typename T> explicit regular(transform_type trans, step_type< T > step, value_type start, value_type stop, metadata_type meta = {}, options_type options = {});Construct bins with the given step size over real transformed range [start, stop).
The axis computes the number of bins as n = abs(stop - start) / step, rounded down. This means that stop is an upper limit to the actual value (start + n * step).
Parameters: |
|
template<typename T> explicit regular(step_type< T > step, value_type start, value_type stop, metadata_type meta = {}, options_type options = {});Construct bins with the given step size over real range [start, stop).
The axis computes the number of bins as n = abs(stop - start) / step, rounded down. This means that stop is an upper limit to the actual value (start + n * step).
Parameters: |
|
regular(const regular & src, index_type begin, index_type end, unsigned merge);Constructor used by algorithm::reduce to shrink and rebin (not for users).
const transform_type & transform() const noexcept;Return instance of the transform type.
index_type index(value_type x) const noexcept;Return index for value argument.
std::pair< index_type, index_type > update(value_type x) noexcept;Returns index and shift (if axis has grown) for the passed argument.
value_type value(real_index_type i) const noexcept;Return value for fractional index argument.
decltype(auto) bin(index_type idx) const noexcept;Return bin for index argument.
index_type size() const noexcept;Returns the number of bins, without over- or underflow.
template<typename V, typename T, typename M, typename O> bool operator==(const regular< V, T, M, O > & o) const noexcept;
template<typename V, typename T, typename M, typename O> bool operator!=(const regular< V, T, M, O > & o) const noexcept;
template<typename Archive> void serialize(Archive & ar, unsigned);