Changeset 273382 for src/unittests/vectorunittest.cpp
- Timestamp:
- Apr 13, 2010, 1:22:42 PM (15 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:
- 1bd79e
- Parents:
- 72e7fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/vectorunittest.cpp
r72e7fa r273382 72 72 CPPUNIT_ASSERT_EQUAL( Vector(2.,3.,4.), fixture ); 73 73 // summation and scaling 74 fixture.CopyVector(&zero); 75 fixture.AddVector(&unit); 76 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 77 fixture.CopyVector(&zero); 78 fixture.SubtractVector(&unit); 74 fixture = zero + unit; 75 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 76 fixture = zero - unit; 79 77 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 80 78 CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() ); 81 fixture.CopyVector(&zero); 82 fixture.AddVector(&zero); 79 fixture = zero + zero; 83 80 CPPUNIT_ASSERT_EQUAL( true, fixture.IsZero() ); 84 fixture.CopyVector(¬unit); 85 fixture.SubtractVector(&otherunit); 86 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 87 fixture.CopyVector(&unit); 88 fixture.AddVector(&otherunit); 81 fixture = notunit - otherunit; 82 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 83 fixture = unit - otherunit; 89 84 CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() ); 90 fixture.CopyVector(¬unit); 91 fixture.SubtractVector(&unit); 92 fixture.SubtractVector(&otherunit); 85 fixture = notunit - unit - otherunit; 93 86 CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() ); 94 fixture.CopyVector(&unit); 95 fixture.Scale(0.98); 87 fixture = 0.98 * unit; 96 88 CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() ); 97 fixture.CopyVector(&unit); 98 fixture.Scale(1.); 99 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 100 fixture.CopyVector(&unit); 89 fixture = 1. * unit; 90 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 101 91 factor = 0.98; 102 fixture .Scale(factor);92 fixture = factor * unit; 103 93 CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() ); 104 fixture.CopyVector(&unit);105 94 factor = 1.; 106 fixture .Scale(factor);95 fixture = factor * unit; 107 96 CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() ); 108 97 }; … … 134 123 void VectorTest::EuclidianScalarProductTest() 135 124 { 136 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct( &zero) );137 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct( &unit) );138 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct( &otherunit) );139 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct( ¬unit) );140 CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct( &unit) );141 CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct( &unit) );142 CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct( &unit) );143 CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct( ¬unit) );144 CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct( &unit) );145 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct( &otherunit) );146 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct( ¬unit) );125 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(zero) ); 126 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(unit) ); 127 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(otherunit) ); 128 CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(notunit) ); 129 CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(unit) ); 130 CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) ); 131 CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) ); 132 CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(notunit) ); 133 CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(unit) ); 134 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(otherunit) ); 135 CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(notunit) ); 147 136 } 148 137 … … 165 154 void VectorTest::EuclidianDistancesTest() 166 155 { 167 CPPUNIT_ASSERT_EQUAL( 1., zero.Distance( &unit) );168 CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance( &unit) );169 CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance( ¬unit) );170 CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance( ¬unit) );171 CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance( ¬unit) );156 CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(unit) ); 157 CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(unit) ); 158 CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance(notunit) ); 159 CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(notunit) ); 160 CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(notunit) ); 172 161 } 173 162 … … 176 165 void VectorTest::EuclidianAnglesTest() 177 166 { 178 CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle( &unit) );179 CPPUNIT_ASSERT_EQUAL( 0., unit.Angle( &unit) );180 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle( &unit)) < MYEPSILON );181 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle( ¬unit)) < MYEPSILON );182 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle( ¬unit)) < MYEPSILON );167 CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(unit) ); 168 CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(unit) ); 169 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(unit)) < MYEPSILON ); 170 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(notunit)) < MYEPSILON ); 171 CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(notunit)) < MYEPSILON ); 183 172 }; 184 173 … … 187 176 void VectorTest::ProjectionTest() 188 177 { 189 CPPUNIT_ASSERT_EQUAL( zero, zero.Projection( &unit) );190 CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection( &unit) );191 CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.), otherunit.Projection( &two) );192 CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.), two.Projection( &otherunit) );178 CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(unit) ); 179 CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(unit) ); 180 CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.), otherunit.Projection(two) ); 181 CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.), two.Projection(otherunit) ); 193 182 }; 194 183
Note:
See TracChangeset
for help on using the changeset viewer.