Ignore:
Timestamp:
Nov 16, 2012, 2:13:45 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
8a0e78
Parents:
d199cc
git-author:
Frederik Heber <heber@…> (08/03/12 08:13:46)
git-committer:
Frederik Heber <heber@…> (11/16/12 14:13:45)
Message:

(Orthogonal)Summator now have internal instance Summation.

  • added createValues() and getSubsets() that are called in cstor to create the necessary variables for (Orthogonal)Summator's cstor.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/Summator.hpp

    rd199cc ra96b02  
    2020#include "Jobs/MPQCDataMap.hpp"
    2121
    22 /** Summator is a general class for making us of OrthogonalSummation.
     22/** Summator is a general class for making us of Summation.
    2323 *
    2424 * The idea is that we want to sum up not only one value but a whole bunch of.
     
    3232 * key. Via this key, which is a type and hence can be used for template
    3333 * specification, we may gather all information for launching the
    34  * OrthogonalSummation. We only need to convert MPQCData into the above
     34 * Summation. We only need to convert MPQCData into the above
    3535 * MPQCDataMap_t instance and may then access the member variables via the above
    3636 * key and also obtain the type at \b run-time through the key.
     
    7373      const IndexSetContainer::Container_t &_container,
    7474      std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */
    75     subsetmap(_subsetmap),
    76     data(_data),
    77     jobids(_jobids),
    78     container(_container),
    79     MatrixNrLookup(_MatrixNrLookup)
     75    indices(getSubsets(_container)),
     76    values(createValues(_data, _jobids, _container, _MatrixNrLookup)),
     77    OS(indices, values, _subsetmap)
    8078  {
    81     ASSERT( data.size() == jobids.size(),
     79    ASSERT( _data.size() == _jobids.size(),
    8280        "Summator() - data and ids don't have same size.");
    83     ASSERT( jobids.size() == MatrixNrLookup.size(),
     81    ASSERT( _jobids.size() == _MatrixNrLookup.size(),
    8482        "Summator() - ids and MatrixNrLookup don't have same size.");
    8583  }
     
    8785  /** Summation operator.
    8886   *
    89    * Initialises instantiated OrthogonalSummation of the respective type via
    90    * \a Summator::data, uses OrthogonalSummation::operator() to sum and returns
     87   * Initialises instantiated Summation of the respective type via
     88   * \a Summator::data, uses Summation::operator() to sum and returns
    9189   * the result.
    9290   *
    93    * \return result of OrthogonalSummation for given type from MPQCDataMap_t.
     91   * \param level up to which level to sum up
     92   * \return result of Summation for given type from MPQCDataMap_t.
    9493   */
    95   MapValue operator()()
     94  MapValue operator()(/* const size_t level */)
     95  {
     96    // evaluate
     97    const MapValue result = OS();
     98    return result;
     99  }
     100
     101private:
     102  /** Tiny helper to create the indices from a given IndexSetContainer.
     103   *
     104   * Basically, we just have to make sure we miss the last one but only
     105   * if the \a container has more than one set.
     106   *
     107   * @param container container with IndexSet
     108   * @return all subsets contained in \a container
     109   */
     110  typename Summation<MapValue>::InputSets_t getSubsets(
     111      const IndexSetContainer::Container_t &container)
    96112  {
    97113    // if we just have one indexset, we don't need to get rid of the "union index set"
     
    99115        container.begin(),
    100116        container.end()-1 == container.begin() ? container.end() : container.end()-1);
     117    return indices;
     118  }
     119
     120  /** Tiny helper to create the values for the summation in the correct order.
     121   *
     122   * @param data
     123   * @param jobids
     124   * @param container
     125   * @param MatrixNrLookup
     126   * @return
     127   */
     128  typename Summation<MapValue>::InputValues_t createValues(
     129      const std::vector<MapType> &data,
     130      const std::vector<JobId_t> &jobids,
     131      const IndexSetContainer::Container_t &container,
     132      std::map< JobId_t, size_t > &MatrixNrLookup)
     133  {
     134    // if we just have one indexset, we don't need to get rid of the "union index set"
    101135    typename Summation<MapValue>::InputValues_t values(
    102136        container.size() == 1 ? (size_t)1 : container.size()-1);
     
    108142      values[ MatrixNrLookup[*iditer] ] = value;
    109143    }
    110 
    111     // create the summation functor and evaluate
    112     Summation<MapValue> OS(indices, values, subsetmap);
    113     const MapValue result = OS();
    114     return result;
     144    return values;
    115145  }
    116 
    117146private:
    118   //!> Hierarchy of IndexSet's
    119   SubsetMap::ptr &subsetmap;
    120   //!> vector of data converted from MPQCData
    121   const std::vector<MapType> &data;
    122   //!> vector of jobids
    123   const std::vector<JobId_t> &jobids;
    124   //!> container with all IndexSet's
    125   const IndexSetContainer::Container_t &container;
    126   //!> lookup map from job ids to ordering in above vectors
    127   std::map< JobId_t, size_t > MatrixNrLookup;
     147  //!> created indices for OS such that we may hand over refs
     148  typename Summation<MapValue>::InputSets_t indices;
     149  //!> created values for OS such that we may hand over refs
     150  typename Summation<MapValue>::InputValues_t values;
     151  //!> Summation instance to use in operator()(level)
     152  Summation<MapValue> OS;
    128153};
    129154
Note: See TracChangeset for help on using the changeset viewer.