Accumulator.qbk 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. [/
  2. Copyright Hans Dembinski 2018 - 2019.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. https://www.boost.org/LICENSE_1_0.txt)
  6. ]
  7. [section:Accumulator Accumulator]
  8. An [*Accumulator] is a functor which consumes the argument to update some internal state. The state can be read with member functions or free functions. Must be [@https://en.cppreference.com/w/cpp/named_req/DefaultConstructible DefaultConstructible], [@https://en.cppreference.com/w/cpp/named_req/CopyConstructible CopyConstructible], and [@https://en.cppreference.com/w/cpp/named_req/CopyAssignable CopyAssignable].
  9. [heading Required features]
  10. * `A` is a type meeting the requirements of [*Accumulator]
  11. * `a` and `b` are values of type `A`
  12. * `ts...` is a pack of values of arbitrary types
  13. [table Valid expressions
  14. [[Expression] [Returns] [Semantics, Pre/Post-conditions]]
  15. [
  16. [`a(ts...)` or `++a`]
  17. []
  18. [
  19. Either a call operator accepting a fixed number of arguments must be implemented, or the pre-increment operator. The call operator may not be templated and not overloaded, except to support weights as described under optional features.
  20. ]
  21. ]
  22. [
  23. [`a == b`]
  24. [`bool`]
  25. [
  26. Returns `true` if all state variables compare equal. Otherwise returns `false`.
  27. ]
  28. ]
  29. [
  30. [`a != b`]
  31. [`bool`]
  32. [
  33. Must be implemented if `a == b` is implemented and must be equal to `!(a == b)`.
  34. ]
  35. ]
  36. ]
  37. [heading Optional features]
  38. * `A` is a type meeting the requirements of [*Accumulator]
  39. * `a` and `b` are values of type `A`
  40. * `w` is a value of type [classref boost::histogram::weight_type], where `T` is a number type
  41. * `ts...` is a pack of values of arbitrary types
  42. * `v` is a number value (integral or floating point)
  43. [table Valid expressions
  44. [[Expression] [Return] [Semantics, Pre/Post-conditions]]
  45. [
  46. [`a += v` or `a(w, ts...)`]
  47. []
  48. [
  49. Does a weighted fill of the accumulator. Use this to implement weight support for an accumulator that is normally filled with `++a` or `a(ts...)`, respectively. Only the corresponding matching form may be implemented: `a += v` for `++a`, `a(w, ts...)` for `a(ts...)`. The implementations may not be templated and not overloaded.
  50. ]
  51. ]
  52. [
  53. [`a += b`]
  54. [`A&`]
  55. [
  56. Adds a second accumulator `b` of type `A`. The result must be the same as if `a` had been filled with all arguments of `b`.
  57. ]
  58. ]
  59. [
  60. [`a *= x`]
  61. [`A&`]
  62. [
  63. Scales the accumulator state by the real value `x`. The result must be the same as if `a` had been filled with all arguments scaled by `x`.
  64. ]
  65. ]
  66. [
  67. [`os << a`]
  68. [`std::basic_ostream<CharT, Traits>&`]
  69. [
  70. `os` is a value of type `std::basic_ostream<CharT, Traits>`. Streams a text representation of the axis. May not mutate `a`.
  71. ]
  72. ]
  73. [
  74. [`a.serialize(ar, n)`]
  75. []
  76. [
  77. `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved.
  78. ]
  79. ]
  80. ]
  81. [heading Models]
  82. * [classref boost::histogram::accumulators::sum]
  83. * [classref boost::histogram::accumulators::weighted_sum]
  84. * [classref boost::histogram::accumulators::mean]
  85. * [classref boost::histogram::accumulators::weighted_mean]
  86. [endsect]