/* * SumUpPerLevel.hpp * * Created on: Aug 27, 2012 * Author: heber */ #ifndef SUMUPPERLEVEL_HPP_ #define SUMUPPERLEVEL_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "Fragmentation/Summation/Converter/DataConverter.hpp" #include "Fragmentation/Summation/AllLevelSummator.hpp" #include "Fragmentation/Summation/IndexSet.hpp" #include "Fragmentation/Summation/IndexSetContainer.hpp" #include "Fragmentation/Summation/Containers/MPQCData.hpp" #include template struct SumUpPerLevel { SumUpPerLevel(const std::map &fragmentData) { // place data into boost::fusion::map instance convertDataTo(fragmentData, Data_fused); // initialize zero instance map ZeroInstanceInitializer initZeroInstance(ZeroInstances); boost::mpl::for_each(boost::ref(initZeroInstance)); } /** Setter for a specific zero value for the given \a MapValue type. * * \param _zeroinstance zero instance to set for type \a MapValue */ template void setZeroInstance( const typename boost::fusion::result_of::value_at_key::type &_zeroinstance) { boost::fusion::at_key(ZeroInstances) = _zeroinstance; } /** Perform the actual summation for each type in \a TypeMap, given by * \a TypeVector. * * i.e. we boost::fusion::for_each over each type in \a TypeVector and perform * an AllLevelSummator on the type. * * \param MatrixNrLookup lookup from job number to a consecutive index in a vector, starting at 0 * \param container container of all indexsets * \param subsetmap map with all subsets for each indexset * \param levelresults after summation contains results for each level * \param keysetresults after summation contains results for each keyset */ void operator()( const std::map< JobId_t, size_t > &MatrixNrLookup, const IndexSetContainer::ptr &container, SubsetMap::ptr &subsetmap, std::vector &levelresults, std::map > &keysetresults ) { // instantiate summator levelresults.resize(subsetmap->getMaximumSetLevel()); AllLevelSummator Summer( subsetmap, Data_fused, container->getContainer(), MatrixNrLookup, levelresults, keysetresults, ZeroInstances); // sum up for each type key in TypeVector boost::mpl::for_each(boost::ref(Summer)); } //!> map with all jobs placed into boost::fusion::maps std::map Data_fused; //!> zero instances to use in summation TypeMap ZeroInstances; }; #endif /* SUMUPPERLEVEL_HPP_ */