Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template variable

boost::histogram::axis::variable — Axis for non-equidistant bins on the real line.

Synopsis

// 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:
  // construct/copy/destruct
  explicit variable(allocator_type = {});
  variable(const variable &) = default;
  variable(variable &&) noexcept;
  template<typename It> 
    variable(It, It, metadata_type = {}, allocator_type = {});
  template<typename U> 
    variable(const U &, metadata_type = {}, allocator_type = {});
  template<typename U> 
    variable(std::initializer_list< U >, metadata_type = {}, 
             allocator_type = {});
  variable(const variable &, index_type, index_type, unsigned);
  variable & operator=(const variable &) = default;
  variable & operator=(variable &&) noexcept;

  // public member functions
  index_type index(value_type) const noexcept;
  auto update(value_type) noexcept;
  value_type value(real_index_type) const noexcept;
  auto bin(index_type) const noexcept;
  index_type size() const noexcept;
  metadata_type & metadata() noexcept;
  const metadata_type & metadata() 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;
};

Description

Binning is a O(log(N)) operation. If speed matters and the problem domain allows it, prefer a regular axis, possibly with a transform.

Template Parameters

  1. typename Value

    input value type, must be floating point.

  2. typename MetaData

    type to store meta data.

  3. typename Options

    see boost::histogram::axis::option (all values allowed).

  4. typename Allocator

    allocator to use for dynamic memory management.

variable public construct/copy/destruct

  1. explicit variable(allocator_type alloc = {});
  2. variable(const variable &) = default;
  3. variable(variable && o) noexcept;
  4. template<typename It> 
      variable(It begin, It end, metadata_type meta = {}, 
               allocator_type alloc = {});
    Construct from iterator range of bin edges.

    Parameters:

    alloc

    allocator instance to use.

    begin

    begin of edge sequence.

    end

    end of edge sequence.

    meta

    description of the axis.

  5. template<typename U> 
      variable(const U & iterable, metadata_type meta = {}, 
               allocator_type alloc = {});
    Construct variable axis from iterable range of bin edges.

    Parameters:

    alloc

    allocator instance to use.

    iterable

    iterable range of bin edges.

    meta

    description of the axis.

  6. template<typename U> 
      variable(std::initializer_list< U > list, metadata_type meta = {}, 
               allocator_type alloc = {});
    Construct variable axis from initializer list of bin edges.

    Parameters:

    alloc

    allocator instance to use.

    list

    std::initializer_list of bin edges.

    meta

    description of the axis.

  7. variable(const variable & src, index_type begin, index_type end, 
             unsigned merge);
    Constructor used by algorithm::reduce to shrink and rebin (not for users).
  8. variable & operator=(const variable &) = default;
  9. variable & operator=(variable && o) noexcept;

variable public member functions

  1. index_type index(value_type x) const noexcept;
    Return index for value argument.
  2. auto update(value_type x) noexcept;
  3. value_type value(real_index_type i) const noexcept;
    Return value for fractional index argument.
  4. auto bin(index_type idx) const noexcept;
    Return bin for index argument.
  5. index_type size() const noexcept;
    Returns the number of bins, without over- or underflow.
  6. metadata_type & metadata() noexcept;
    Returns reference to metadata.
  7. const metadata_type & metadata() const noexcept;
    Returns reference to const metadata.
  8. template<typename V, typename M, typename O, typename A> 
      bool operator==(const variable< V, M, O, A > & o) const noexcept;
  9. template<typename V, typename M, typename O, typename A> 
      bool operator!=(const variable< V, M, O, A > & o) const noexcept;
  10. auto get_allocator() const;
    Return allocator instance.
  11. template<typename Archive> void serialize(Archive &, unsigned);

variable public static functions

  1. static constexpr unsigned options() noexcept;
    Returns the options.

PrevUpHomeNext