source: src/Fragmentation/Summation/SetValues/IndexedVectors.hpp@ fbf143

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
Last change on this file since fbf143 was fbf143, checked in by Frederik Heber <heber@…>, 12 years ago

Placed Containers, Converter, and SetValues as subfolders into Summation.

  • also libMolecuilderFragmentationSummation is now a shared library, easing linkage to libMolecuilderJobs, and contains all of the three convenience libraries.
  • libMolecuilderFragmentationSetValues is now again convenience, as contained in ..Summation which in turn is shared.
  • KeySetsContainer right now is the link between lib..Summation and lib.. Fragmentation. Hence, we had to extract the module and change it into a shared library, as it is required by libMolecuilderJobs through ..Summation but also by ..Fragmentation that heavily relies on this container.
  • moved parseKeySetFile down into Fragmentation folder to KeySetsContainer, it is also contained in new shared library libMolecuilderFragmentation_ KeySetsContainer.
  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * IndexedVectors.hpp
3 *
4 * Created on: 29.07.2012
5 * Author: heber
6 */
7
8#ifndef INDEXEDVECTORS_HPP_
9#define INDEXEDVECTORS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <map>
18#include <vector>
19
20class IndexedVectorsTest;
21
22/** IndexedVectors represents a class that contains a a set of vectors,
23 * each associated to a specific index. When adding or subtracting only
24 * the ones are combined that have matching indices.
25 *
26 * This is needed for summing up force vectors per nuclei obtained from
27 * fragment calculations.
28 *
29 */
30class IndexedVectors
31{
32 //!> grant unit test access to private parts
33 friend class IndexedVectorsTest;
34public:
35 //!> typedef for a single vector
36 typedef std::vector<double> vector_t;
37 //!> typedef for the index type
38 typedef size_t index_t;
39 //!> typedef for the indices matching the bunch of vectors
40 typedef std::vector<vector_t> vectors_t;
41 //!> typedef for the ordered indices matching the bunch of vectors
42 typedef std::vector<index_t> indices_t;
43 //!> typedef for a bunch of indexed vectors
44 typedef std::map<index_t, vector_t> indexedvectors_t;
45
46 enum SpecificIndices_t {
47 DropIndex = -1
48 };
49
50 /** Default constructor for class IndexedVectors.
51 *
52 */
53 IndexedVectors() {}
54
55 /** Constructor for class IndexedVectors.
56 *
57 * We construct the internal map from \a _indices and \a _vectors. For
58 * every index -1 contained in \a _indices the respective vector in
59 * \a _vectors is \b not added but silently dropped.
60 *
61 * \param _indices index to each vector
62 * \param _vectors vectors
63 */
64 IndexedVectors(const indices_t &_indices, const vectors_t &_vectors);
65
66 /** Assignment operator.
67 *
68 * \note This is required to place IndexedVectors in STL containers.
69 *
70 * \param other other instance to assign this one to
71 * \return ref to this instance
72 */
73 IndexedVectors& operator=(const IndexedVectors &other);
74
75 /** Addition operator with another IndexedVector instance \a other.
76 *
77 * \param other other instance to sum onto this one.
78 * \return ref to this instance
79 */
80 IndexedVectors& operator+=(const IndexedVectors &other)
81 {
82 superposeOtherIndexedVectors(other, +1.);
83 return *this;
84 }
85
86 /** Subtraction operator with another IndexedVector instance \a other.
87 *
88 * \param other other instance to subtract from this one.
89 * \return ref to this instance
90 */
91 IndexedVectors& operator-=(const IndexedVectors &other)
92 {
93 superposeOtherIndexedVectors(other, -1.);
94 return *this;
95 }
96
97private:
98 /** Helper function that contains all the logic of how to superpose two
99 * indexed vectors.
100 *
101 * Is called by IndexedVectors::operator+=() and IndexedVectors::operator-=()
102 *
103 * @param other other histogram
104 * @param prefactor +1. is then addition, -1. is subtraction.
105 */
106 void superposeOtherIndexedVectors(const IndexedVectors &other, const double prefactor);
107
108private:
109 //!> internal map with all indexed vectors
110 indexedvectors_t vectors;
111 //!> fixed size of all vector_t
112 static const size_t FixedSize;
113 //!> static instance representing a null vector
114 static const vector_t nullvector;
115
116 //!> grant access to output operator
117 friend std::ostream & operator<<(std::ostream &ost, const IndexedVectors &other);
118};
119
120/** Output operator for IndexedVector.
121 *
122 * Prints a space-separated list of all members as "(index, vector)".
123 *
124 * \param ost output stream to print to
125 * \param other instance to print
126 * \return ref to ost for concatenation
127 */
128std::ostream & operator<<(std::ostream &ost, const IndexedVectors &other);
129
130template<typename T> T ZeroInstance();
131template<> IndexedVectors ZeroInstance<IndexedVectors>();
132
133
134#endif /* INDEXEDVECTORS_HPP_ */
Note: See TracBrowser for help on using the repository browser.