| Home | Libraries | People | FAQ | More

## Class template weighted_sum

boost::histogram::accumulators::weighted_sum — Holds sum of weights and its variance estimate.

## Synopsis

    // In header: <boost/histogram/accumulators/weighted_sum.hpp>

    template<typename ValueType>
    class weighted_sum {
    public:
      // types
      typedef ValueType          value_type;
      typedef const value_type & const_reference;

      // construct/copy/destruct
      weighted_sum() = default;
      weighted_sum(const_reference) noexcept;
      template<typename T> weighted_sum(const weighted_sum< T > &) noexcept;
      weighted_sum(const_reference, const_reference) noexcept;

      // public member functions
      weighted_sum & operator++();
      weighted_sum & operator+=(const weight_type< value_type > &);
      weighted_sum & operator+=(const weighted_sum &);
      weighted_sum & operator/=(const weighted_sum &);
      weighted_sum & operator*=(const_reference);
      bool operator==(const weighted_sum &) const noexcept;
      bool operator!=(const weighted_sum &) const noexcept;
      const_reference value() const noexcept;
      const_reference variance() const noexcept;
      explicit operator const_reference() const;
      template<typename Archive> void serialize(Archive &, unsigned);
    };

## Description

### `weighted_sum` public construct/copy/destruct

1.     weighted_sum() = default;

2.     weighted_sum(const_reference value) noexcept;

   Initialize sum to value and allow implicit conversion.

3.     template<typename T> weighted_sum(const weighted_sum< T > & s) noexcept;

   Allow implicit conversion from sum<T>

4.     weighted_sum(const_reference value, const_reference variance) noexcept;

   Initialize sum to value and variance.

### `weighted_sum` public member functions

1.     weighted_sum & operator++();

   Increment by one.

2.     weighted_sum & operator+=(const weight_type< value_type > & w);

   Increment by weight.

3.     weighted_sum & operator+=(const weighted_sum & rhs);

   Added another weighted sum.

4.     weighted_sum & operator/=(const weighted_sum & rhs);

   Divide by another weighted sum.

5.     weighted_sum & operator*=(const_reference x);

   Scale by value.

6.     bool operator==(const weighted_sum & rhs) const noexcept;

7.     bool operator!=(const weighted_sum & rhs) const noexcept;

8.     const_reference value() const noexcept;

   Return value of the sum.

9.     const_reference variance() const noexcept;

   Return estimated variance of the sum.

10.     explicit operator const_reference() const;

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