/* * OrthogonalSumUpPerLevel.hpp * * Created on: Aug 27, 2012 * Author: heber */ #ifndef ORTHOGONALSUMUPPERLEVEL_HPP_ #define ORTHOGONALSUMUPPERLEVEL_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "Fragmentation/Summation/Converter/DataConverter.hpp" #include "Fragmentation/Summation/AllLevelOrthogonalSummator.hpp" #include "Fragmentation/Summation/IndexSet.hpp" #include "Fragmentation/Summation/IndexSetContainer.hpp" #include "Fragmentation/Summation/ZeroInstanceInitializer.hpp" #include "Fragmentation/Summation/Containers/MPQCData.hpp" #include template struct OrthogonalSumUpPerLevel { /** Constructor of class OrthogonalSumUpPerLevel. * * This prepares all the data by converting them into boost::fusion::map * format and also initializes the default zero instances used as base * in the summation. * * \param _fragmentData data to sum up per job */ OrthogonalSumUpPerLevel(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 orthogonal 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()); AllLevelOrthogonalSummator 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 /* ORTHOGONALSUMUPPERLEVEL_HPP_ */