Hans Dembinski 1bf9dd9dfd
thread-safe storage
- new thread-safe accumulators for arithmetic types
- storages have a new flag `has_threading_support` to indicate support for parallel cell access
- histogram automatically synchronises growing axes and storage if necessary
2019-04-14 22:24:34 +02:00

115 lines
4.3 KiB
Plaintext

[section:Axis Axis]
An [*Axis] maps input values to indices. It holds state specific to that axis, like the number of bins and any metadata. Must be [@https://en.cppreference.com/w/cpp/named_req/CopyConstructible CopyConstructible] and [@https://en.cppreference.com/w/cpp/named_req/CopyAssignable CopyAssignable].
[heading Associated Types]
* [link histogram.concepts.DiscreteAxis [*DiscreteAxis]]
* [link histogram.concepts.IntervalAxis [*IntervalAxis]]
[heading Required features]
* `A` is a type meeting the requirements of [*Axis]
* `a` is a value of type `A`
* `I` is an alias for [headerref boost/histogram/fwd.hpp `boost::histogram::index_type`]
[table Valid expressions
[[Expression] [Returns] [Semantics, Pre/Post-conditions]]
[
[`a.size()`]
[`I`]
[
Const member function which returns the number of bins of the axis. All indices from `0` to `a.size() - 1` must be valid and address a bin of the axis.
]
]
[
[`a.index(v)`]
[`I`]
[
Const member function which maps a value `v` to an index. The mapping must be injective: each value must be uniquely mapped to one index. If the value is not covered by the axis, return either `-1` or `a.size()`. The value `-1` indicates that the value is lower than the lowest value covered by the axis. The value `a.size()` indicates that the value is above the uppermost value covered by the axis. By convention, /NaN/-values are mapped to `a.size()`.
]
]
[
[`a.get_allocator()`]
[`Alloc`]
[
Const member function which returns the allocator `Alloc` used by this axis. May be omitted if `A` does not use allocators. If this member function exists, also a special constructor must exists so that `A(a.get_allocator())` is a valid expression.
]
]
]
[heading Optional features]
* `A` is a type meeting the requirements of [*Axis]
* `a` and `b` are values of type `A`
* `M` is a metadata type that is [@https://en.cppreference.com/w/cpp/named_req/CopyConstructible CopyConstructible] and [@https://en.cppreference.com/w/cpp/named_req/CopyAssignable CopyAssignable]
[table Valid expressions
[[Expression] [Returns] [Semantics, Pre/Post-conditions]]
[
[`a.update(v)`]
[`std::pair<I, I>`]
[
Non-const member function which maps a value to an index (first argument of the returned pair) and offset (second argument of the returned pair). If the value is not covered by the axis, this method may grow the current axis size (`old_size`) by the number of bins needed to contain the value or more (`new_size`). If the value is below the lowest value covered by the axis, return index `0` and offset `new_size - old_size`. If the value is above the uppermost value covered by the axis, return index `new_size - 1` and a negative offset `old_size - new_size`. If the value is outside, but the axis is not enlarged, then return an index equivalent to `a.index(v)` and offset `0`.
]
]
[
[`a.options()`]
[`unsigned`]
[
Static constexpr member function which returns the [headerref boost/histogram/axis/option.hpp axis options] for this axis.
]
]
[
[`a.metadata()`]
[`const M&`]
[
Const member function which returns a const reference to the metadata associated with the axis (usually a string).
]
]
[
[`a.metadata()`]
[`M&`]
[
Likewise, but non-const member function which returns a reference to the metadata. If this member function exists, also the previous one must exist.
]
]
[
[`a == b`]
[`bool`]
[
Returns `true` if all state variables compare equal, including any metadata. Otherwise returns `false`. If `a == b` is implemented, also `a != b` must be implemented. If this binary operator is not implemented, the library considers the arguments equal, if and only if their types are the same.
]
]
[
[`a != b`]
[`bool`]
[
Must be implemented if `a == b` is implemented and must be equal to `!(a == b)`.
]
]
[
[`os << a`]
[`std::basic_ostream<CharT, Traits>&`]
[
`os` is a value of type `std::basic_ostream<CharT, Traits>`. Streams a text representation of the axis. May not mutate `a`.
]
]
[
[`ar & a`]
[]
[
`ar` is a value of an archive with Boost.Serialization semantics. Serializes `a` to the archive or loads serialized state from the archive.
]
]
]
[heading Models]
* [classref boost::histogram::axis::category]
* [classref boost::histogram::axis::integer]
* [classref boost::histogram::axis::regular]
* [classref boost::histogram::axis::variable]
[endsect]