Changeset 6e06bd for src/unittests/MatrixUnittest.cpp
- Timestamp:
- Dec 5, 2010, 12:19:19 AM (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, Candidate_v1.7.0, 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:
- f03705
- Parents:
- 589112 (diff), bbf1bd (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. - File:
-
- 1 edited
-
src/unittests/MatrixUnittest.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/MatrixUnittest.cpp
r589112 r6e06bd 26 26 #include "MatrixUnittest.hpp" 27 27 #include "LinearAlgebra/Vector.hpp" 28 #include "LinearAlgebra/ Matrix.hpp"28 #include "LinearAlgebra/RealSpaceMatrix.hpp" 29 29 #include "Exceptions/NotInvertibleException.hpp" 30 30 … … 37 37 38 38 void MatrixUnittest::setUp(){ 39 zero = new Matrix(); 40 one = new Matrix(); 39 zero = new RealSpaceMatrix(); 40 for(int i =NDIM;i--;) { 41 for(int j =NDIM;j--;) { 42 zero->at(i,j)=0.; 43 } 44 } 45 one = new RealSpaceMatrix(); 41 46 for(int i =NDIM;i--;){ 42 47 one->at(i,i)=1.; 43 48 } 44 full=new Matrix();49 full=new RealSpaceMatrix(); 45 50 for(int i=NDIM;i--;){ 46 51 for(int j=NDIM;j--;){ … … 48 53 } 49 54 } 50 diagonal = new Matrix();55 diagonal = new RealSpaceMatrix(); 51 56 for(int i=NDIM;i--;){ 52 57 diagonal->at(i,i)=i+1.; 53 58 } 54 perm1 = new Matrix();59 perm1 = new RealSpaceMatrix(); 55 60 perm1->column(0) = unitVec[0]; 56 61 perm1->column(1) = unitVec[2]; … … 58 63 59 64 60 perm2 = new Matrix();65 perm2 = new RealSpaceMatrix(); 61 66 perm2->column(0) = unitVec[1]; 62 67 perm2->column(1) = unitVec[0]; 63 68 perm2->column(2) = unitVec[2]; 64 69 65 perm3 = new Matrix();70 perm3 = new RealSpaceMatrix(); 66 71 perm3->column(0) = unitVec[1]; 67 72 perm3->column(1) = unitVec[2]; 68 73 perm3->column(2) = unitVec[0]; 69 74 70 perm4 = new Matrix();75 perm4 = new RealSpaceMatrix(); 71 76 perm4->column(0) = unitVec[2]; 72 77 perm4->column(1) = unitVec[1]; 73 78 perm4->column(2) = unitVec[0]; 74 79 75 perm5 = new Matrix();80 perm5 = new RealSpaceMatrix(); 76 81 perm5->column(0) = unitVec[2]; 77 82 perm5->column(1) = unitVec[0]; … … 92 97 93 98 void MatrixUnittest::AccessTest(){ 94 Matrix mat;99 RealSpaceMatrix mat; 95 100 for(int i=NDIM;i--;){ 96 101 for(int j=NDIM;j--;){ … … 114 119 115 120 void MatrixUnittest::VectorTest(){ 116 Matrix mat;121 RealSpaceMatrix mat; 117 122 for(int i=NDIM;i--;){ 118 123 CPPUNIT_ASSERT_EQUAL(mat.row(i),zeroVec); … … 121 126 CPPUNIT_ASSERT_EQUAL(mat.diagonal(),zeroVec); 122 127 123 mat. one();128 mat.setIdentity(); 124 129 CPPUNIT_ASSERT_EQUAL(mat.row(0),unitVec[0]); 125 130 CPPUNIT_ASSERT_EQUAL(mat.row(1),unitVec[1]); … … 168 173 169 174 void MatrixUnittest::TransposeTest(){ 170 Matrix res;175 RealSpaceMatrix res; 171 176 172 177 // transpose of unit is unit 173 res. one();174 (const Matrix)res.transpose();178 res.setIdentity(); 179 res.transpose(); 175 180 CPPUNIT_ASSERT_EQUAL(res,*one); 176 181 177 182 // transpose of transpose is same matrix 178 res. zero();183 res.setZero(); 179 184 res.set(2,2, 1.); 180 185 CPPUNIT_ASSERT_EQUAL(res.transpose().transpose(),res); … … 182 187 183 188 void MatrixUnittest::OperationTest(){ 184 Matrix res;189 RealSpaceMatrix res; 185 190 186 191 res =(*zero) *(*zero); 192 std::cout << *zero << " times " << *zero << " is " << res << std::endl; 187 193 CPPUNIT_ASSERT_EQUAL(res,*zero); 188 194 res =(*zero) *(*one); … … 254 260 255 261 void MatrixUnittest::RotationTest(){ 256 Matrix res;257 Matrix inverse;262 RealSpaceMatrix res; 263 RealSpaceMatrix inverse; 258 264 259 265 // zero rotation angles yields unity matrix 260 res. rotation(0,0,0);266 res.setRotation(0,0,0); 261 267 CPPUNIT_ASSERT_EQUAL(*one, res); 262 268 263 269 // arbitrary rotation matrix has det = 1 264 res. rotation(M_PI/3.,1.,M_PI/7.);270 res.setRotation(M_PI/3.,1.,M_PI/7.); 265 271 CPPUNIT_ASSERT(fabs(fabs(res.determinant()) -1.) < MYEPSILON); 266 272 267 273 // inverse is rotation matrix with negative angles 268 res. rotation(M_PI/3.,0.,0.);269 inverse. rotation(-M_PI/3.,0.,0.);274 res.setRotation(M_PI/3.,0.,0.); 275 inverse.setRotation(-M_PI/3.,0.,0.); 270 276 CPPUNIT_ASSERT_EQUAL(*one, res * inverse); 271 277 272 278 // ... or transposed 273 res. rotation(M_PI/3.,0.,0.);274 CPPUNIT_ASSERT_EQUAL(inverse, ((const Matrix) res).transpose());279 res.setRotation(M_PI/3.,0.,0.); 280 CPPUNIT_ASSERT_EQUAL(inverse, ((const RealSpaceMatrix) res).transpose()); 275 281 } 276 282 … … 279 285 CPPUNIT_ASSERT_THROW(full->invert(),NotInvertibleException); 280 286 281 Matrix res;287 RealSpaceMatrix res; 282 288 res = (*one)*one->invert(); 283 289 CPPUNIT_ASSERT_EQUAL(res,*one);
Note:
See TracChangeset
for help on using the changeset viewer.
