Ignore:
Timestamp:
Dec 5, 2010, 12:19:19 AM (15 years ago)
Author:
Frederik Heber <heber@…>
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.
Message:

Merge branch 'MatrixVectorContentRefactoring' into stable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/MatrixUnittest.cpp

    r589112 r6e06bd  
    2626#include "MatrixUnittest.hpp"
    2727#include "LinearAlgebra/Vector.hpp"
    28 #include "LinearAlgebra/Matrix.hpp"
     28#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2929#include "Exceptions/NotInvertibleException.hpp"
    3030
     
    3737
    3838void 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();
    4146  for(int i =NDIM;i--;){
    4247    one->at(i,i)=1.;
    4348  }
    44   full=new Matrix();
     49  full=new RealSpaceMatrix();
    4550  for(int i=NDIM;i--;){
    4651    for(int j=NDIM;j--;){
     
    4853    }
    4954  }
    50   diagonal = new Matrix();
     55  diagonal = new RealSpaceMatrix();
    5156  for(int i=NDIM;i--;){
    5257    diagonal->at(i,i)=i+1.;
    5358  }
    54   perm1 = new Matrix();
     59  perm1 = new RealSpaceMatrix();
    5560  perm1->column(0) = unitVec[0];
    5661  perm1->column(1) = unitVec[2];
     
    5863
    5964
    60   perm2 = new Matrix();
     65  perm2 = new RealSpaceMatrix();
    6166  perm2->column(0) = unitVec[1];
    6267  perm2->column(1) = unitVec[0];
    6368  perm2->column(2) = unitVec[2];
    6469
    65   perm3 = new Matrix();
     70  perm3 = new RealSpaceMatrix();
    6671  perm3->column(0) = unitVec[1];
    6772  perm3->column(1) = unitVec[2];
    6873  perm3->column(2) = unitVec[0];
    6974
    70   perm4 = new Matrix();
     75  perm4 = new RealSpaceMatrix();
    7176  perm4->column(0) = unitVec[2];
    7277  perm4->column(1) = unitVec[1];
    7378  perm4->column(2) = unitVec[0];
    7479
    75   perm5 = new Matrix();
     80  perm5 = new RealSpaceMatrix();
    7681  perm5->column(0) = unitVec[2];
    7782  perm5->column(1) = unitVec[0];
     
    9297
    9398void MatrixUnittest::AccessTest(){
    94   Matrix mat;
     99  RealSpaceMatrix mat;
    95100  for(int i=NDIM;i--;){
    96101    for(int j=NDIM;j--;){
     
    114119
    115120void MatrixUnittest::VectorTest(){
    116   Matrix mat;
     121  RealSpaceMatrix mat;
    117122  for(int i=NDIM;i--;){
    118123    CPPUNIT_ASSERT_EQUAL(mat.row(i),zeroVec);
     
    121126  CPPUNIT_ASSERT_EQUAL(mat.diagonal(),zeroVec);
    122127
    123   mat.one();
     128  mat.setIdentity();
    124129  CPPUNIT_ASSERT_EQUAL(mat.row(0),unitVec[0]);
    125130  CPPUNIT_ASSERT_EQUAL(mat.row(1),unitVec[1]);
     
    168173
    169174void MatrixUnittest::TransposeTest(){
    170   Matrix res;
     175  RealSpaceMatrix res;
    171176
    172177  // transpose of unit is unit
    173   res.one();
    174   (const Matrix)res.transpose();
     178  res.setIdentity();
     179  res.transpose();
    175180  CPPUNIT_ASSERT_EQUAL(res,*one);
    176181
    177182  // transpose of transpose is same matrix
    178   res.zero();
     183  res.setZero();
    179184  res.set(2,2, 1.);
    180185  CPPUNIT_ASSERT_EQUAL(res.transpose().transpose(),res);
     
    182187
    183188void MatrixUnittest::OperationTest(){
    184   Matrix res;
     189  RealSpaceMatrix res;
    185190
    186191  res =(*zero) *(*zero);
     192  std::cout << *zero << " times " << *zero << " is " << res << std::endl;
    187193  CPPUNIT_ASSERT_EQUAL(res,*zero);
    188194  res =(*zero) *(*one);
     
    254260
    255261void MatrixUnittest::RotationTest(){
    256   Matrix res;
    257   Matrix inverse;
     262  RealSpaceMatrix res;
     263  RealSpaceMatrix inverse;
    258264
    259265  // zero rotation angles yields unity matrix
    260   res.rotation(0,0,0);
     266  res.setRotation(0,0,0);
    261267  CPPUNIT_ASSERT_EQUAL(*one, res);
    262268
    263269  // 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.);
    265271  CPPUNIT_ASSERT(fabs(fabs(res.determinant()) -1.) < MYEPSILON);
    266272
    267273  // 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.);
    270276  CPPUNIT_ASSERT_EQUAL(*one, res * inverse);
    271277
    272278  // ... 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());
    275281}
    276282
     
    279285  CPPUNIT_ASSERT_THROW(full->invert(),NotInvertibleException);
    280286
    281   Matrix res;
     287  RealSpaceMatrix res;
    282288  res = (*one)*one->invert();
    283289  CPPUNIT_ASSERT_EQUAL(res,*one);
Note: See TracChangeset for help on using the changeset viewer.