| 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;

      // public member functions
      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;
      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 member functions

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.

5.     weighted_sum & operator++();

   Increment by one.

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

   Increment by weight.

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

   Added another weighted sum.

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

   Divide by another weighted sum.

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

   Scale by value.

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

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

12.     const_reference value() const noexcept;

    Return value of the sum.

13.     const_reference variance() const noexcept;

    Return estimated variance of the sum.

14.     explicit operator const_reference() const;

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