| Home | Libraries | People | FAQ | More

## Class template regular

boost::histogram::axis::regular — Axis for equidistant intervals on the real line.

## Synopsis

    // 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 unsigned options() noexcept;
    };

## Description

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` and`circular` are mutually exclusive.

### Template Parameters

1.     typename Value

   input value type, must be floating point.

2.     typename Transform

   builtin or user-defined transform type.

3.     typename MetaData

   type to store meta data.

4.     typename Options

   see boost::histogram::axis::option.

### `regular` public member functions

1.     regular() = default;

2.     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: |
   `trans` | transform instance to use.
   `n` | number of bins.
   `start` | low edge of first bin.
   `stop` | high edge of last bin.
   `meta` | description of the axis (optional).
   `options` | see boost::histogram::axis::option (optional).

3.     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: |
   `n` | number of bins.
   `start` | low edge of first bin.
   `stop` | high edge of last bin.
   `meta` | description of the axis (optional).
   `options` | see boost::histogram::axis::option (optional).

4.     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: |
   `trans` | transform instance to use.
   `step` | width of a single bin.
   `start` | low edge of first bin.
   `stop` | upper limit of high edge of last bin (see below).
   `meta` | description of the axis (optional).
   `options` | see boost::histogram::axis::option (optional).

5.     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: |
   `step` | width of a single bin.
   `start` | low edge of first bin.
   `stop` | upper limit of high edge of last bin (see below).
   `meta` | description of the axis (optional).
   `options` | see boost::histogram::axis::option (optional).

6.     regular(const regular & src, index_type begin, index_type end, unsigned merge);

   Constructor used by algorithm::reduce to shrink and rebin (not for users).

7.     const transform_type & transform() const noexcept;

   Return instance of the transform type.

8.     index_type index(value_type x) const noexcept;

   Return index for value argument.

9.     std::pair< index_type, index_type > update(value_type x) noexcept;

   Returns index and shift (if axis has grown) for the passed argument.

10.     value_type value(real_index_type i) const noexcept;

    Return value for fractional index argument.

11.     decltype(auto) bin(index_type idx) const noexcept;

    Return bin for index argument.

12.     index_type size() const noexcept;

    Returns the number of bins, without over- or underflow.

13.     template<typename V, typename T, typename M, typename O>
          bool operator==(const regular< V, T, M, O > & o) const noexcept;

14.     template<typename V, typename T, typename M, typename O>
          bool operator!=(const regular< V, T, M, O > & o) const noexcept;

15.     template<typename Archive> void serialize(Archive & ar, unsigned);

### `regular` public static functions

1.     static unsigned options() noexcept;

   Returns the options.