/* * Summation.hpp * * Created on: Jun 30, 2012 * Author: heber */ #ifndef SUMMATION_HPP_ #define SUMMATION_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include "SetValue.hpp" #include "SubsetMap.hpp" #include "SetValueMap.hpp" /** Summation is a functor executing a simple summation of SetValue's * that are each associated to a certain IndexSet whose union is a SetOfIndexSets. * * This is kept in signature alike to OrthogonalSummation. * * For the given class we require the following functions: * -# operator=(): assignment operator for placement in vector * -# operator+=(): addition operator for adding one instance from another * -# operator-=(): subtraction operator for subtracting one instance from another * -# operator<<(): output operator */ template class Summation { public: typedef std::vector< IndexSet::ptr > InputSets_t; typedef std::vector< T > InputValues_t; Summation(InputSets_t &indices, InputValues_t& values, SubsetMap::ptr _subsetmap = SubsetMap::ptr()); /** Performs the summation and returns result. * * @param level sum up to this level * @return resulting value */ T operator()(const size_t level) const; /** Returns const reference to internal setvalues. * * @return const reference to internal setvalues. */ const SetValueMap & getSetValues() const { return setvalues; } /** Setter for the zero instance to use as the base in summation. * * This may be used to force some parameters in the summation. We * will use this value to set the initial value and all contributions * are added via operator+(). E.g. In summing SamplingGrid (charge * grids) we may use this instance to enforce a smaller grid size * in the summation of the contributions if fragments have been * calculated at a much higher grid level. * * \param _zeroinstance */ void setZeroInstance(const T &_zeroinstance) { zeroinstance = _zeroinstance; } private: T Sum(const size_t level) const; private: //!> SubsetTree with the tree-like structure of subsets SubsetMap::ptr subsetmap; //!> set of all subset values SetValueMap setvalues; //!> base/"zero" instance to sum upon, defaults to ZeroInstance T zeroinstance; }; #include "Summation_impl.hpp" #endif /* SUMMATION_HPP_ */