Changeset 36bb2d for src/Fragmentation/Summation
- Timestamp:
- Nov 20, 2012, 11:04:12 AM (13 years ago)
- 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, Candidate_v1.7.0, Candidate_v1.7.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:
- a22e05
- Parents:
- cebac0 (diff), a1436b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Fragmentation/Summation
- Files:
-
- 11 added
- 14 edited
- 1 moved
-
AllLevelOrthogonalSummator.hpp (added)
-
AllLevelSummator.hpp (moved) (moved from src/Fragmentation/Summation/printSum.hpp ) (7 diffs)
-
HeaderPrinter.hpp (added)
-
IndexSetContainer.cpp (added)
-
IndexSetContainer.hpp (modified) (2 diffs)
-
Makefile.am (modified) (1 diff)
-
OrthogonalSummation.hpp (modified) (2 diffs)
-
OrthogonalSummation_impl.hpp (modified) (2 diffs)
-
OrthogonalSummator.hpp (added)
-
SetValue.hpp (modified) (1 diff)
-
SubsetMap.cpp (modified) (1 diff)
-
SubsetMap.hpp (modified) (1 diff)
-
Summation.hpp (added)
-
Summation_impl.hpp (added)
-
Summator.hpp (modified) (5 diffs)
-
ValuePrinter.hpp (added)
-
ZeroInstance.hpp (added)
-
unittests/IndexSetContainerUnitTest.cpp (modified) (2 diffs)
-
unittests/IndexSetContainerUnitTest.hpp (modified) (2 diffs)
-
unittests/Makefile.am (modified) (5 diffs)
-
unittests/OrthogonalSummationUnitTest.cpp (modified) (2 diffs)
-
unittests/SubsetMapUnitTest.cpp (modified) (1 diff)
-
unittests/SubsetMapUnitTest.hpp (modified) (2 diffs)
-
unittests/SummationUnitTest.cpp (added)
-
unittests/SummationUnitTest.hpp (added)
-
writeTable.hpp (added)
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/AllLevelSummator.hpp
rcebac0 r36bb2d 1 1 /* 2 * printSum.hpp2 * AllLevelSummator.hpp 3 3 * 4 4 * Created on: 29.07.2012 … … 6 6 */ 7 7 8 #ifndef PRINTSUM_HPP_9 #define PRINTSUM_HPP_8 #ifndef ALLLEVELSUMMATOR_HPP_ 9 #define ALLLEVELSUMMATOR_HPP_ 10 10 11 11 // include config.h … … 16 16 #include <vector> 17 17 18 #include "CodePatterns/Assert.hpp" 19 18 20 #include "Fragmentation/Summation/IndexSetContainer.hpp" 19 21 #include "Fragmentation/Summation/SubsetMap.hpp" … … 22 24 #include "Fragmentation/Summation/printKeyNames.hpp" 23 25 24 /** Tiny template functor to use OrthogonalSummation, sum up and print the result. 26 /** Tiny template functor to use Summation, sum up each level, and store the 27 * result in a given vector. 25 28 * 26 29 */ 27 30 template <typename MapType> 28 struct printSum{31 struct AllLevelSummator { 29 32 /** Constructor takes the arguments that \a Summator also needs and stores 30 33 * them internally. … … 36 39 * to job id and hence to _data. 37 40 * \param _MatrixNrLookup lookup from job id to ordering in above vectors 41 * \param _results vector place results into 38 42 */ 39 printSum(43 AllLevelSummator( 40 44 SubsetMap::ptr &_subsetmap, 41 45 const std::vector<MapType> &_data, 42 46 const std::vector<JobId_t> &_jobids, 43 47 const IndexSetContainer::Container_t &_container, 44 std::map< JobId_t, size_t > &_MatrixNrLookup) : /* cannot make this const due to operator[] */ 48 std::map< JobId_t, size_t > &_MatrixNrLookup, /* cannot make this const due to operator[] */ 49 std::vector<MapType> &_results) : 45 50 subsetmap(_subsetmap), 46 51 data(_data), 47 52 jobids(_jobids), 48 53 container(_container), 49 MatrixNrLookup(_MatrixNrLookup) 50 {} 54 MatrixNrLookup(_MatrixNrLookup), 55 results(_results) 56 { 57 ASSERT( results.size() >= subsetmap->getMaximumSubsetLevel(), 58 "AllLevelSummator() - result vector is not large enough."); 59 } 51 60 52 61 /** Operator that calls on Summator and prints the value. … … 63 72 subsetmap, data, jobids, container, MatrixNrLookup 64 73 ); 65 // sum up 66 MapValue value = sum_value(); 67 // print value 68 LOG(0, "STATUS: Resulting " << printKeyNames::printName<MapKey>() << " is " << value << "."); 74 const size_t MaxLevel = subsetmap->getMaximumSubsetLevel(); 75 for (size_t level=1; level <= MaxLevel; ++level) { 76 MapType &LevelResults = results[level-1]; 77 // sum up and store in results 78 const MapValue value = sum_value(level); 79 boost::fusion::at_key<MapKey>(LevelResults) = value; 80 // print value 81 //LOG(0, "STATUS: Level " << level << " resulting " << printKeyNames::printName<MapKey>() << " is " << value << "."); 82 } 69 83 } 70 84 … … 80 94 //!> lookup map from job ids to ordering in above vectors 81 95 std::map< JobId_t, size_t > MatrixNrLookup; 96 //!> vector of results 97 std::vector<MapType> &results; 82 98 }; 83 99 84 #endif /* PRINTSUM_HPP_ */100 #endif /* ALLLEVELSUMMATOR_HPP_ */ -
src/Fragmentation/Summation/IndexSetContainer.hpp
rcebac0 r36bb2d 22 22 23 23 class IndexSetContainerTest; 24 class KeySetsContainer; 24 25 25 26 /** … … 63 64 SortedVector<IndexSet>(_instance) 64 65 {} 66 67 /** Conversion constructor from a KeySetConntainer. 68 * 69 * We create the super set of all found key sets and then each single set, 70 * while always dropping indices equal to -1. 71 * 72 * @param _keysets keysets to turn into IndexSets 73 */ 74 explicit IndexSetContainer(const KeySetsContainer &_keysets); 75 76 /** Sum up the number of IndexSets with indices less or equal to \a level. 77 * 78 * Sadly, we have to re-implement a binary search as size_t != IndexSet::ptr. 79 * 80 * @param level maximum set size 81 * @return number of sets up till \a level 82 */ 83 size_t countSetsTillLevel(const size_t level) const; 84 85 private: 86 /** Helper function to get the super set out of a KeySetsContainer. 87 * 88 * @param _keysets keysets to construct super set for 89 * @return IndexSet that contains each index once that appears in the sets of \a _keysets 90 */ 91 IndexSet::ptr& createSuperSet(const KeySetsContainer &_keysets) const; 92 93 //!> static instance for AllIndices such that createSuperSet may return a reference. 94 static IndexSet::ptr AllIndices; 65 95 }; 96 66 97 //!> typedef for IndexSet instance stored as shared_ptr in SortedVector 67 98 typedef IndexSetContainer::T_ptr IndexSet_ptr; -
src/Fragmentation/Summation/Makefile.am
rcebac0 r36bb2d 4 4 FRAGMENTATIONSUMMATIONSOURCE = \ 5 5 Fragmentation/Summation/IndexSet.cpp \ 6 Fragmentation/Summation/IndexSetContainer.cpp \ 6 7 Fragmentation/Summation/SubsetMap.cpp 7 8 8 9 FRAGMENTATIONSUMMATIONHEADER = \ 10 Fragmentation/Summation/AllLevelOrthogonalSummator.hpp \ 11 Fragmentation/Summation/AllLevelSummator.hpp \ 12 Fragmentation/Summation/HeaderPrinter.hpp \ 9 13 Fragmentation/Summation/IndexSet.hpp \ 10 14 Fragmentation/Summation/IndexSetContainer.hpp \ 11 15 Fragmentation/Summation/OrthogonalSummation.hpp \ 12 16 Fragmentation/Summation/OrthogonalSummation_impl.hpp \ 17 Fragmentation/Summation/OrthogonalSummator.hpp \ 13 18 Fragmentation/Summation/printKeyNames.hpp \ 14 Fragmentation/Summation/printSum.hpp \15 19 Fragmentation/Summation/SetValue.hpp \ 16 20 Fragmentation/Summation/SetValueMap.hpp \ 17 21 Fragmentation/Summation/SortedVector.hpp \ 18 22 Fragmentation/Summation/SubsetMap.hpp \ 19 Fragmentation/Summation/Summator.hpp 23 Fragmentation/Summation/Summation.hpp \ 24 Fragmentation/Summation/Summation_impl.hpp \ 25 Fragmentation/Summation/Summator.hpp \ 26 Fragmentation/Summation/ValuePrinter.hpp \ 27 Fragmentation/Summation/writeTable.hpp \ 28 Fragmentation/Summation/ZeroInstance.hpp 20 29 21 30 -
src/Fragmentation/Summation/OrthogonalSummation.hpp
rcebac0 r36bb2d 25 25 * 26 26 * For the given class we require the following functions: 27 * -# operator=(): assig ment operator for placement in vector27 * -# operator=(): assignment operator for placement in vector 28 28 * -# operator+=(): addition operator for adding one instance from another 29 29 * -# operator-=(): subtraction operator for subtracting one instance from another … … 40 40 /** Performs the orthogonal summation and returns result. 41 41 * 42 * @param level sum up to this level 42 43 * @return resulting value 43 44 */ 44 T operator()() const; 45 T operator()(const size_t level) const; 46 47 /** Returns const reference to internal setvalues. 48 * 49 * @return const reference to internal setvalues. 50 */ 51 const SetValueMap<T> & getSetValues() const { 52 return setvalues; 53 } 45 54 46 55 private: 47 T Sum( ) const;56 T Sum(const size_t level) const; 48 57 49 58 private: -
src/Fragmentation/Summation/OrthogonalSummation_impl.hpp
rcebac0 r36bb2d 17 17 #include "CodePatterns/IteratorAdaptors.hpp" 18 18 #include "CodePatterns/Log.hpp" 19 20 #include "Fragmentation/Summation/ZeroInstance.hpp" 19 21 20 22 /** Constructor of class OrthogonalSummation. … … 57 59 58 60 template <class T> 59 T OrthogonalSummation<T>::operator()( ) const61 T OrthogonalSummation<T>::operator()(const size_t level) const 60 62 { 61 return Sum( );63 return Sum(level); 62 64 } 63 65 64 66 template <class T> 65 T OrthogonalSummation<T>::Sum( ) const67 T OrthogonalSummation<T>::Sum(const size_t level) const 66 68 { 67 69 typename SetValueMap<T>::const_iterator iter = setvalues.begin(); 68 T sum = (iter->second)->getContribution(); 70 T sum(ZeroInstance<T>()); 71 if (iter->first->size() <= level) 72 sum = (iter->second)->getContribution(); 69 73 LOG(1, "DEBUG: Contribution from subset "+toString(*(iter->second->getIndexSet())) 70 74 +" is "+toString(sum)+"."); 71 for(++iter; iter != setvalues.end(); ++iter) {75 for(++iter;(iter != setvalues.end()) && (iter->first->size() <= level); ++iter) { 72 76 const T tempvalue = (iter->second)->getContribution(); 73 77 sum += tempvalue; -
src/Fragmentation/Summation/SetValue.hpp
rcebac0 r36bb2d 34 34 //!> grant OrthogonalSummation access to static lookup functions 35 35 template <class TT> friend class OrthogonalSummation; 36 //!> grant Summation access to static lookup functions 37 template <class TT> friend class Summation; 36 38 public: 37 39 typedef boost::shared_ptr< SetValue<T> > ptr; -
src/Fragmentation/Summation/SubsetMap.cpp
rcebac0 r36bb2d 183 183 return indexset; 184 184 } 185 186 size_t SubsetMap::getMaximumSubsetLevel() const 187 { 188 // last one is super set, hence, the one before has largest subset size 189 Lookup_t::const_iterator iter = --Lookup.end(); 190 --iter; 191 return iter->first->size(); 192 } 193 194 size_t SubsetMap::getMaximumSetLevel() const 195 { 196 // last one is super set 197 Lookup_t::const_iterator iter = --Lookup.end(); 198 return iter->first->size(); 199 } -
src/Fragmentation/Summation/SubsetMap.hpp
rcebac0 r36bb2d 59 59 } 60 60 61 /** Returns the size of the largest \b sub set. 62 * 63 * This would be \f${\cal O}(n)\f$ if we had to look at each set. However, due 64 * to the specific sorting we just have to check the last sets. 65 * 66 * @return number of indices in largest subset, -1 if SubsetMap contains no IndexSet's 67 */ 68 size_t getMaximumSubsetLevel() const; 69 70 /** Returns the size of the largest set. 71 * 72 * @return number of indices in largest set 73 */ 74 size_t getMaximumSetLevel() const; 75 61 76 private: 62 77 /** Private function to fill the internal Lookup for a given IndexSet \a ptr. -
src/Fragmentation/Summation/Summator.hpp
rcebac0 r36bb2d 16 16 #include <boost/fusion/sequence.hpp> 17 17 18 #include "Fragmentation/Summation/ OrthogonalSummation.hpp"18 #include "Fragmentation/Summation/Summation.hpp" 19 19 #include "Fragmentation/Summation/SetValue.hpp" 20 20 #include "Jobs/MPQCDataMap.hpp" 21 21 22 /** Summator is a general class for making us of OrthogonalSummation.22 /** Summator is a general class for making us of Summation. 23 23 * 24 24 * The idea is that we want to sum up not only one value but a whole bunch of. … … 32 32 * key. Via this key, which is a type and hence can be used for template 33 33 * specification, we may gather all information for launching the 34 * OrthogonalSummation. We only need to convert MPQCData into the above34 * Summation. We only need to convert MPQCData into the above 35 35 * MPQCDataMap_t instance and may then access the member variables via the above 36 36 * key and also obtain the type at \b run-time through the key. … … 73 73 const IndexSetContainer::Container_t &_container, 74 74 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) 80 78 { 81 ASSERT( data.size() ==jobids.size(),79 ASSERT( _data.size() == _jobids.size(), 82 80 "Summator() - data and ids don't have same size."); 83 ASSERT( jobids.size() ==MatrixNrLookup.size(),81 ASSERT( _jobids.size() == _MatrixNrLookup.size(), 84 82 "Summator() - ids and MatrixNrLookup don't have same size."); 85 83 } … … 87 85 /** Summation operator. 88 86 * 89 * Initialises instantiated OrthogonalSummation of the respective type via90 * \a Summator::data, uses OrthogonalSummation::operator() to sum and returns87 * Initialises instantiated Summation of the respective type via 88 * \a Summator::data, uses Summation::operator() to sum and returns 91 89 * the result. 92 90 * 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. 94 93 */ 95 MapValue operator()() 94 MapValue operator()(const size_t level) 95 { 96 // evaluate 97 const MapValue result = OS(level); 98 return result; 99 } 100 101 private: 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) 96 112 { 97 113 // if we just have one indexset, we don't need to get rid of the "union index set" 98 typename OrthogonalSummation<MapValue>::InputSets_t indices(114 typename Summation<MapValue>::InputSets_t indices( 99 115 container.begin(), 100 116 container.end()-1 == container.begin() ? container.end() : container.end()-1); 101 typename OrthogonalSummation<MapValue>::InputValues_t values( 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" 135 typename Summation<MapValue>::InputValues_t values( 102 136 container.size() == 1 ? (size_t)1 : container.size()-1); 103 137 typename std::vector<MapType>::const_iterator dataiter = data.begin(); … … 108 142 values[ MatrixNrLookup[*iditer] ] = value; 109 143 } 110 111 // create the summation functor and evaluate 112 OrthogonalSummation<MapValue> OS(indices, values, subsetmap); 113 const MapValue result = OS(); 114 return result; 144 return values; 115 145 } 116 117 146 private: 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; 128 153 }; 129 154 -
src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp
rcebac0 r36bb2d 45 45 #include <boost/assign.hpp> 46 46 #include <boost/foreach.hpp> 47 48 #include "Fragmentation/KeySetsContainer.hpp" 47 49 48 50 #ifdef HAVE_TESTRUNNER … … 138 140 CPPUNIT_ASSERT( !SV->ContainerSorted ); 139 141 } 142 143 /** Unit tests for cstr(KeySetsContainer) 144 * 145 */ 146 void IndexSetContainerTest::KeySetContainerTest() 147 { 148 KeySetsContainer keysets; 149 KeySetsContainer::IntVector vector1; 150 vector1 += 1,-1; 151 KeySetsContainer::IntVector vector2; 152 vector2 += -1,1,2,-1; 153 keysets.KeySets.push_back(vector1); 154 keysets.KeySets.push_back(vector2); 155 SV = new IndexSetContainer(keysets); 156 157 // check sets 158 CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer().size() ); 159 CPPUNIT_ASSERT_EQUAL( (size_t)1, SV->getContainer()[0]->size() ); 160 CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer()[1]->size() ); 161 162 } 163 164 /** Unit tests for countSetsTillLevel() 165 * 166 */ 167 void IndexSetContainerTest::countSetsTillLevelTest() 168 { 169 SV = new IndexSetContainer(allsets); 170 171 CPPUNIT_ASSERT_EQUAL( (size_t)0, SV->countSetsTillLevel(0) ); 172 CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->countSetsTillLevel(1) ); 173 CPPUNIT_ASSERT_EQUAL( (size_t)4, SV->countSetsTillLevel(2) ); 174 CPPUNIT_ASSERT_EQUAL( (size_t)5, SV->countSetsTillLevel(3) ); 175 CPPUNIT_ASSERT_EQUAL( (size_t)6, SV->countSetsTillLevel(4) ); 176 CPPUNIT_ASSERT_EQUAL( (size_t)6, SV->countSetsTillLevel(5) ); 177 } -
src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp
rcebac0 r36bb2d 30 30 CPPUNIT_TEST ( comparatorTest ); 31 31 CPPUNIT_TEST ( insertTest ); 32 CPPUNIT_TEST ( KeySetContainerTest ); 33 CPPUNIT_TEST ( countSetsTillLevelTest ); 32 34 CPPUNIT_TEST_SUITE_END(); 33 35 … … 38 40 void comparatorTest(); 39 41 void insertTest(); 42 void KeySetContainerTest(); 43 void countSetsTillLevelTest(); 40 44 41 45 private: -
src/Fragmentation/Summation/unittests/Makefile.am
rcebac0 r36bb2d 8 8 ../Fragmentation/Summation/unittests/SetValueUnitTest.cpp \ 9 9 ../Fragmentation/Summation/unittests/SetValueMapUnitTest.cpp \ 10 ../Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp 10 ../Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp \ 11 ../Fragmentation/Summation/unittests/SummationUnitTest.cpp 11 12 12 13 FRAGMENTATIONSUMMATIONTESTSHEADERS = \ … … 16 17 ../Fragmentation/Summation/unittests/SetValueUnitTest.hpp \ 17 18 ../Fragmentation/Summation/unittests/SetValueMapUnitTest.hpp \ 18 ../Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp 19 ../Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp \ 20 ../Fragmentation/Summation/unittests/SummationUnitTest.hpp 19 21 20 22 FRAGMENTATIONSUMMATIONTESTS = \ … … 24 26 SetValueUnitTest \ 25 27 SetValueMapUnitTest \ 26 SubsetMapUnitTest 28 SubsetMapUnitTest \ 29 SummationUnitTest 27 30 28 31 TESTS += $(FRAGMENTATIONSUMMATIONTESTS) … … 44 47 ../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp \ 45 48 ../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp 46 IndexSetContainerUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS} 49 IndexSetContainerUnitTest_LDADD = \ 50 ../libMolecuilderFragmentation.la \ 51 ../libMolecuilderHelpers.la \ 52 ${FRAGMENTATIONSUMMATIONLIBS} 47 53 48 54 OrthogonalSummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 49 55 ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp \ 50 ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp 56 ../Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.hpp \ 57 ../Fragmentation/Summation/OrthogonalSummation.hpp \ 58 ../Fragmentation/Summation/OrthogonalSummation_impl.hpp 51 59 OrthogonalSummationUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS} 52 60 … … 68 76 SubsetMapUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS} 69 77 78 SummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 79 ../Fragmentation/Summation/unittests/SummationUnitTest.cpp \ 80 ../Fragmentation/Summation/unittests/SummationUnitTest.hpp \ 81 ../Fragmentation/Summation/Summation.hpp \ 82 ../Fragmentation/Summation/Summation_impl.hpp 83 SummationUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS} 84 70 85 71 86 #AUTOMAKE_OPTIONS = parallel-tests -
src/Fragmentation/Summation/unittests/OrthogonalSummationUnitTest.cpp
rcebac0 r36bb2d 59 59 // Registers the fixture into the 'registry' 60 60 CPPUNIT_TEST_SUITE_REGISTRATION( OrthogonalSummationTest ); 61 //62 //template <class T>63 //struct SetValueAllocator {64 // SetValueAllocator(const T &_value) :65 // value(_value)66 // {}67 // SetValue<T> * operator()(const IndexSet &set) {68 // SetValue<T> * _instance = new SetValue<T>(set, value);69 // return _instance;70 // }71 //private:72 // //!> internally stored fixed initial value73 // const T value;74 //};75 61 76 62 void OrthogonalSummationTest::setUp() … … 119 105 120 106 // sum up, as full set is contained we must get value again 121 CPPUNIT_ASSERT_EQUAL( value, OS() ); 107 //CPPUNIT_ASSERT_EQUAL( 0, OS(0) ); /* zero value is not guaranteed to bet set to zero. */ 108 CPPUNIT_ASSERT_EQUAL( value*2, OS(1) ); 109 CPPUNIT_ASSERT_EQUAL( value*2, OS(2) ); 110 CPPUNIT_ASSERT_EQUAL( value*2, OS(3) ); 111 CPPUNIT_ASSERT_EQUAL( value, OS(4) ); 112 CPPUNIT_ASSERT_EQUAL( value, OS(5) ); 122 113 } 123 114 } -
src/Fragmentation/Summation/unittests/SubsetMapUnitTest.cpp
rcebac0 r36bb2d 300 300 } 301 301 } 302 303 /** UnitTest for getMaximumSubsetLevel() 304 */ 305 void SubsetMapTest::getMaximumSubsetLevelTest() 306 { 307 // create small container 308 { 309 IndexSet tempset; 310 std::vector<IndexSet> sets; 311 sets.push_back(tempset); 312 tempset += 1; 313 sets.push_back(tempset); 314 tempset += 2; 315 sets.push_back(tempset); 316 tempset.clear(); 317 tempset += 2; 318 sets.push_back(tempset); 319 IndexSetContainer container( sets ); 320 // now we have {}, {1}, {2}, {1,2} in container 321 322 SM = new SubsetMap(container); 323 CPPUNIT_ASSERT( SM != NULL ); 324 325 CPPUNIT_ASSERT_EQUAL( (size_t)1, SM->getMaximumSubsetLevel() ); 326 // we are strictly less than super set (last one) 327 CPPUNIT_ASSERT( SM->getMaximumSubsetLevel() < (--SM->Lookup.end())->first->size() ); 328 } 329 330 // create larger container 331 { 332 IndexSetContainer container( allsets ); 333 delete SM; 334 SM = new SubsetMap(container); 335 CPPUNIT_ASSERT( SM != NULL ); 336 337 CPPUNIT_ASSERT_EQUAL( (size_t)3, SM->getMaximumSubsetLevel() ); 338 CPPUNIT_ASSERT( SM->getMaximumSubsetLevel() < (--SM->Lookup.end())->first->size() ); 339 } 340 } -
src/Fragmentation/Summation/unittests/SubsetMapUnitTest.hpp
rcebac0 r36bb2d 31 31 CPPUNIT_TEST ( getSubsetTest ); 32 32 CPPUNIT_TEST ( gatherSubsetTest ); 33 CPPUNIT_TEST ( getMaximumSubsetLevelTest ); 33 34 CPPUNIT_TEST_SUITE_END(); 34 35 … … 40 41 void getSubsetTest(); 41 42 void gatherSubsetTest(); 43 void getMaximumSubsetLevelTest(); 42 44 43 45 private:
Note:
See TracChangeset
for help on using the changeset viewer.
