...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::variable — Axis for non-equidistant bins on the real line.
// In header: <boost/histogram/axis/variable.hpp> template<typename Value, typename MetaData, typename Options, typename Allocator> class variable : public boost::histogram::axis::iterator_mixin< variable< Value, MetaData, Options, Allocator > >, public metadata_base_t< MetaData > { public: // construct/copy/destruct variable() = default; explicit variable(allocator_type); template<typename It> variable(It, It, metadata_type = {}, options_type = {}, allocator_type = {}); template<typename It> variable(It, It, metadata_type, allocator_type); template<typename U> variable(const U &, metadata_type = {}, options_type = {}, allocator_type = {}); template<typename U> variable(const U &, metadata_type, allocator_type); template<typename U> variable(std::initializer_list< U >, metadata_type = {}, options_type = {}, allocator_type = {}); template<typename U> variable(std::initializer_list< U >, metadata_type, allocator_type); variable(const variable &, index_type, index_type, unsigned); // public member functions 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; auto bin(index_type) const noexcept; index_type size() const noexcept; template<typename V, typename M, typename O, typename A> bool operator==(const variable< V, M, O, A > &) const noexcept; template<typename V, typename M, typename O, typename A> bool operator!=(const variable< V, M, O, A > &) const noexcept; auto get_allocator() const; template<typename Archive> void serialize(Archive &, unsigned); // public static functions static constexpr unsigned options() noexcept; };
Binning is a O(log(N)) operation. If speed matters and the problem domain allows it, prefer a regular axis, possibly with a transform.
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. This is the desired behavior for random numbers drawn from a bounded interval, which is usually closed.
typename Value
input value type, must be floating point.
typename MetaData
type to store meta data.
typename Options
see boost::histogram::axis::option.
typename Allocator
allocator to use for dynamic memory management.
variable
public
construct/copy/destructvariable() = default;
explicit variable(allocator_type alloc);
template<typename It> variable(It begin, It end, metadata_type meta = {}, options_type options = {}, allocator_type alloc = {});Construct from iterator range of bin edges.
Parameters: |
|
template<typename It> variable(It begin, It end, metadata_type meta, allocator_type alloc);
template<typename U> variable(const U & iterable, metadata_type meta = {}, options_type options = {}, allocator_type alloc = {});Construct variable axis from iterable range of bin edges.
Parameters: |
|
template<typename U> variable(const U & iterable, metadata_type meta, allocator_type alloc);
template<typename U> variable(std::initializer_list< U > list, metadata_type meta = {}, options_type options = {}, allocator_type alloc = {});Construct variable axis from initializer list of bin edges.
Parameters: |
|
template<typename U> variable(std::initializer_list< U > list, metadata_type meta, allocator_type alloc);
variable(const variable & src, index_type begin, index_type end, unsigned merge);Constructor used by algorithm::reduce to shrink and rebin (not for users).
variable
public member functionsindex_type index(value_type x) const noexcept;Return index for value argument.
std::pair< index_type, index_type > update(value_type x) noexcept;
value_type value(real_index_type i) const noexcept;Return value for fractional index argument.
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 M, typename O, typename A> bool operator==(const variable< V, M, O, A > & o) const noexcept;
template<typename V, typename M, typename O, typename A> bool operator!=(const variable< V, M, O, A > & o) const noexcept;
auto get_allocator() const;Return allocator instance.
template<typename Archive> void serialize(Archive & ar, unsigned);