Lattice Builder Manual
Software Package for Constructing Rank-1 Lattices
|
Accumulator template class. More...
#include <Accumulator.h>
Public Types | |
typedef VAL | value_type |
Type of the values fed to the accumulator. | |
typedef ACCVAL | accumulator_value_type |
Type of the accumulator value. | |
Public Member Functions | |
Accumulator (accumulator_value_type initialValue) | |
void | accumulate (const value_type &value) |
Feeds a new value to the accumulator. | |
void | accumulate (Real weight, const value_type &value, Real power=1.0) |
Feeds value multiplied by weight to the accumulator. More... | |
const value_type & | value () const |
Returns the current value of the accumulator. | |
accumulator_value_type & | value () |
Static Public Member Functions | |
static std::string | name () |
Returns the name of the operator implemented by the accumulator. | |
Accumulator template class.
An accumulator holds a value that can be updated by feeding it with new values with the accumulate() member function. The scalar binary operation by which new values are combined with the current value is specified with the OP template parameter. If the values are vectorial (indexable with the [] operator), the operator OP is applied to each element of the vector through the LatBuilder::Vectorize class template.
OP | Class template that takes that provides the implementation of a scalar binary operator. Must implement the static member functions name() , that returns a string that identifies the operator, and apply(current_accumulator_value,new_value) , which returns the new accumulator value when a value new_value is fed to the accumulator while the current accumulator value is current_accumulator_value . For examples, see Functor::Sum::name() and Functor::Sum::apply(). |
VAL | Type of the values that are fed to the accumulator. |
ACCVAL | Type of the accumulator value (in most cases it should be the same as VAL). |
|
inline |
Feeds value
multiplied by weight
to the accumulator.
weight
is assumed to already be raised at the power power
.
References LatBuilder::Accumulator< OP, VAL, ACCVAL >::value().