Changeset f6ad4d
- Timestamp:
- Mar 28, 2012, 8:17:35 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, 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:
- 53bc04
- Parents:
- 418b5e
- git-author:
- Frederik Heber <heber@…> (03/14/12 16:14:03)
- git-committer:
- Frederik Heber <heber@…> (03/28/12 08:17:35)
- Location:
- LinearAlgebra/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
LinearAlgebra/src/LinearAlgebra/VectorSet.hpp
r418b5e rf6ad4d 18 18 #include <algorithm> 19 19 #include <limits> 20 #include <boost/bind.hpp> 20 21 #include <boost/lambda/bind.hpp> 21 22 #include <boost/lambda/lambda.hpp> … … 28 29 29 30 #include "Vector.hpp" 31 30 32 #include <vector> 33 #include "RealSpaceMatrix.hpp" 31 34 32 35 // this tests, whether we actually have a Vector … … 50 53 51 54 VectorSet(){} 55 VectorSet(const Set &_set) : Set(_set) {} 52 56 virtual ~VectorSet(){} 57 58 /** 59 * transform all Vectors within this set by a RealSpaceMatrix 60 */ 61 void transform(const RealSpaceMatrix &M){ 62 // this is needed to allow template lookup 63 std::transform(this->begin(),this->end(),this->begin(), 64 boost::bind(static_cast<Vector(*)(const RealSpaceMatrix&,const Vector&)>(operator*), M, _1)); 65 } 53 66 54 67 /** … … 57 70 void translate(const Vector &translater){ 58 71 // this is needed to allow template lookup 59 std::transform(this->begin(),this->end(),this->begin(),std::bind1st(std::plus<Vector>(),translater)); 72 std::transform(this->begin(),this->end(),this->begin(), 73 std::bind1st(std::plus<Vector>(),translater)); 60 74 } 61 75 -
LinearAlgebra/src/unittests/VectorSetUnitTest.cpp
r418b5e rf6ad4d 25 25 26 26 #include "VectorSetUnitTest.hpp" 27 28 #include "RealSpaceMatrix.hpp" 29 #include "VectorSet.hpp" 27 30 28 31 #ifdef HAVE_TESTRUNNER … … 56 59 } 57 60 61 /** UnitTest for Cstor(Set &) 62 */ 63 void VectorSetTest::copyConstructorTest() 64 { 65 VECTORSET(std::vector) worklist(list); 66 CPPUNIT_ASSERT_EQUAL( list.size(), worklist.size() ); 67 std::vector<Vector>::const_iterator iter = list.begin(); 68 VECTORSET(std::vector)::const_iterator workiter = worklist.begin(); 69 for (;(iter != list.end()) && (workiter != worklist.end()); ++iter, ++workiter) 70 CPPUNIT_ASSERT( ((*iter)) == (*workiter) ); 71 } 72 73 58 74 /** UnitTest for translate() 59 75 */ … … 69 85 } 70 86 87 /** UnitTest for transform() 88 */ 89 void VectorSetTest::transformTest() 90 { 91 VECTORSET(std::vector) worklist(list); 92 RealSpaceMatrix M; 93 M.setIdentity(); 94 M *= 2.; 95 worklist.transform(M); 96 VECTORSET(std::vector)::const_iterator iter = list.begin(); 97 VECTORSET(std::vector)::const_iterator workiter = worklist.begin(); 98 for (;(iter != list.end()) && (workiter != worklist.end()); ++iter, ++workiter) 99 CPPUNIT_ASSERT( (2.*(*iter)) == (*workiter) ); 100 } 101 71 102 /** UnitTest for minDistance() 72 103 */ 73 104 void VectorSetTest::minDistanceTest() 74 105 { 106 VECTORSET(std::vector) worklist(list); 75 107 { 76 108 VECTORSET(std::vector) somelist; … … 83 115 { 84 116 Vector center(5.,0.,0.); 85 Vector mindist = list.minDistance(center);117 Vector mindist = worklist.minDistance(center); 86 118 CPPUNIT_ASSERT_EQUAL (Vector(2., 1., 0.)-center, mindist); 87 119 } 88 120 { 89 for (VECTORSET(std::vector)::const_iterator iter = list.begin();90 iter != list.end(); ++iter) {91 Vector mindist = list.minDistance(*iter);121 for (VECTORSET(std::vector)::const_iterator iter = worklist.begin(); 122 iter != worklist.end(); ++iter) { 123 Vector mindist = worklist.minDistance(*iter); 92 124 CPPUNIT_ASSERT_EQUAL( Vector(0.,0.,0.), mindist ); 93 125 } … … 99 131 void VectorSetTest::minDistSquaredTest() 100 132 { 133 VECTORSET(std::vector) worklist(list); 101 134 { 102 135 Vector center(5.,0.,0.); 103 double mindist = list.minDistSquared(center);136 double mindist = worklist.minDistSquared(center); 104 137 double check = Vector(2., 1., 0.).DistanceSquared(center); 105 138 CPPUNIT_ASSERT_EQUAL( check, mindist ); 106 139 } 107 140 { 108 for (VECTORSET(std::vector)::const_iterator iter = list.begin();109 iter != list.end(); ++iter) {110 double mindist = list.minDistSquared(*iter);141 for (VECTORSET(std::vector)::const_iterator iter = worklist.begin(); 142 iter != worklist.end(); ++iter) { 143 double mindist = worklist.minDistSquared(*iter); 111 144 CPPUNIT_ASSERT_EQUAL( 0., mindist ); 112 145 } -
LinearAlgebra/src/unittests/VectorSetUnitTest.hpp
r418b5e rf6ad4d 17 17 #include <cppunit/extensions/HelperMacros.h> 18 18 19 #include "VectorSet.hpp" 19 #include <vector> 20 21 #include "Vector.hpp" 20 22 21 23 /********************************************** Test classes **************************************/ … … 24 26 { 25 27 CPPUNIT_TEST_SUITE( VectorSetTest) ; 28 CPPUNIT_TEST ( copyConstructorTest ); 26 29 CPPUNIT_TEST ( translateTest ); 30 CPPUNIT_TEST ( transformTest ); 27 31 CPPUNIT_TEST ( minDistanceTest ); 28 32 CPPUNIT_TEST ( minDistSquaredTest ); … … 33 37 void tearDown(); 34 38 39 void copyConstructorTest(); 35 40 void translateTest(); 41 void transformTest(); 36 42 void minDistanceTest(); 37 43 void minDistSquaredTest(); 38 44 39 45 private: 40 VECTORSET(std::vector)list;46 std::vector<Vector> list; 41 47 }; 42 48
Note:
See TracChangeset
for help on using the changeset viewer.