Ignore:
Timestamp:
Dec 4, 2010, 11:54:32 PM (14 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, 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:
0d4424
Parents:
3bc926
git-author:
Frederik Heber <heber@…> (11/15/10 12:58:27)
git-committer:
Frederik Heber <heber@…> (12/04/10 23:54:32)
Message:

Renamed Matrix to RealSpaceMatrix.

  • class Matrix only represents 3x3 matrices, whereas we are now going to extend the class MatrixContent to contain arbritrary dimensions.
  • renamed class and file
File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/LinearAlgebra/RealSpaceMatrix.cpp

    r3bc926 rcca9ef  
    77
    88/*
    9  * Matrix.cpp
     9 * RealSpaceMatrix.cpp
    1010 *
    1111 *  Created on: Jun 25, 2010
     
    2020#include "Helpers/MemDebug.hpp"
    2121
    22 #include "LinearAlgebra/Matrix.hpp"
     22#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2323#include "Helpers/Assert.hpp"
    2424#include "Exceptions/NotInvertibleException.hpp"
     
    3939using namespace std;
    4040
    41 Matrix::Matrix()
     41RealSpaceMatrix::RealSpaceMatrix()
    4242{
    4343  content = new MatrixContent(NDIM, NDIM);
     
    4545}
    4646
    47 Matrix::Matrix(const double* src)
     47RealSpaceMatrix::RealSpaceMatrix(const double* src)
    4848{
    4949  content = new MatrixContent(NDIM, NDIM, src);
     
    5151}
    5252
    53 Matrix::Matrix(const Matrix &src)
     53RealSpaceMatrix::RealSpaceMatrix(const RealSpaceMatrix &src)
    5454{
    5555  content = new MatrixContent(src.content);
     
    5757}
    5858
    59 Matrix::Matrix(const MatrixContent &src)
     59RealSpaceMatrix::RealSpaceMatrix(const MatrixContent &src)
    6060{
    6161  content = new MatrixContent(src);
     
    6363}
    6464
    65 Matrix::Matrix(MatrixContent* _content)
     65RealSpaceMatrix::RealSpaceMatrix(MatrixContent* _content)
    6666{
    6767  content = new MatrixContent(_content);
     
    6969}
    7070
    71 Matrix::~Matrix()
     71RealSpaceMatrix::~RealSpaceMatrix()
    7272{
    7373  // delete all views
     
    8282}
    8383
    84 void Matrix::createViews(){
     84void RealSpaceMatrix::createViews(){
    8585  // create row views
    8686  for(int i=NDIM;i--;){
     
    9898}
    9999
    100 void Matrix::setIdentity(){
     100void RealSpaceMatrix::setIdentity(){
    101101  content->setIdentity();
    102102}
    103103
    104 void Matrix::setZero(){
     104void RealSpaceMatrix::setZero(){
    105105  content->setZero();
    106106}
    107107
    108 void Matrix::setRotation(const double x, const double y, const double z)
     108void RealSpaceMatrix::setRotation(const double x, const double y, const double z)
    109109{
    110110  set(0,0, cos(y)*cos(z));
     
    119119}
    120120
    121 Matrix &Matrix::operator=(const Matrix &src)
     121RealSpaceMatrix &RealSpaceMatrix::operator=(const RealSpaceMatrix &src)
    122122{
    123123  // MatrixContent checks for self-assignment
     
    126126}
    127127
    128 const Matrix &Matrix::operator+=(const Matrix &rhs)
     128const RealSpaceMatrix &RealSpaceMatrix::operator+=(const RealSpaceMatrix &rhs)
    129129{
    130130  *content += *(rhs.content);
     
    132132}
    133133
    134 const Matrix &Matrix::operator-=(const Matrix &rhs)
     134const RealSpaceMatrix &RealSpaceMatrix::operator-=(const RealSpaceMatrix &rhs)
    135135{
    136136  *content -= *(rhs.content);
     
    138138}
    139139
    140 const Matrix &Matrix::operator*=(const Matrix &rhs)
     140const RealSpaceMatrix &RealSpaceMatrix::operator*=(const RealSpaceMatrix &rhs)
    141141{
    142142  (*content) *= (*rhs.content);
     
    144144}
    145145
    146 const Matrix Matrix::operator+(const Matrix &rhs) const
    147 {
    148   Matrix tmp = *this;
     146const RealSpaceMatrix RealSpaceMatrix::operator+(const RealSpaceMatrix &rhs) const
     147{
     148  RealSpaceMatrix tmp = *this;
    149149  tmp+=rhs;
    150150  return tmp;
    151151}
    152152
    153 const Matrix Matrix::operator-(const Matrix &rhs) const
    154 {
    155   Matrix tmp = *this;
     153const RealSpaceMatrix RealSpaceMatrix::operator-(const RealSpaceMatrix &rhs) const
     154{
     155  RealSpaceMatrix tmp = *this;
    156156  tmp-=rhs;
    157157  return tmp;
    158158}
    159159
    160 const Matrix Matrix::operator*(const Matrix &rhs) const
    161 {
    162   Matrix tmp(content);
     160const RealSpaceMatrix RealSpaceMatrix::operator*(const RealSpaceMatrix &rhs) const
     161{
     162  RealSpaceMatrix tmp(content);
    163163  tmp *= rhs;
    164164  return tmp;
    165165}
    166166
    167 double &Matrix::at(size_t i, size_t j)
     167double &RealSpaceMatrix::at(size_t i, size_t j)
    168168{
    169169  return content->at(i,j);
    170170}
    171171
    172 const double Matrix::at(size_t i, size_t j) const
     172const double RealSpaceMatrix::at(size_t i, size_t j) const
    173173{
    174174  return content->at(i,j);
    175175}
    176176
    177 Vector &Matrix::row(size_t i)
     177Vector &RealSpaceMatrix::row(size_t i)
    178178{
    179179  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
     
    181181}
    182182
    183 const Vector &Matrix::row(size_t i) const
     183const Vector &RealSpaceMatrix::row(size_t i) const
    184184{
    185185  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
     
    187187}
    188188
    189 Vector &Matrix::column(size_t i)
     189Vector &RealSpaceMatrix::column(size_t i)
    190190{
    191191  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
     
    193193}
    194194
    195 const Vector &Matrix::column(size_t i) const
     195const Vector &RealSpaceMatrix::column(size_t i) const
    196196{
    197197  ASSERT(i>=0&&i<NDIM,"Index i for Matrix access out of range");
     
    199199}
    200200
    201 Vector &Matrix::diagonal()
     201Vector &RealSpaceMatrix::diagonal()
    202202{
    203203  return *diagonal_ptr;
    204204}
    205205
    206 const Vector &Matrix::diagonal() const
     206const Vector &RealSpaceMatrix::diagonal() const
    207207{
    208208  return *diagonal_ptr;
    209209}
    210210
    211 void Matrix::set(size_t i, size_t j, const double value)
     211void RealSpaceMatrix::set(size_t i, size_t j, const double value)
    212212{
    213213  content->set(i,j, value);
    214214}
    215215
    216 double Matrix::determinant() const{
     216double RealSpaceMatrix::determinant() const{
    217217  return at(0,0)*at(1,1)*at(2,2)
    218218       + at(0,1)*at(1,2)*at(2,0)
     
    224224
    225225
    226 Matrix Matrix::invert() const{
     226RealSpaceMatrix RealSpaceMatrix::invert() const{
    227227  double det = determinant();
    228228  if(fabs(det)<MYEPSILON){
     
    231231
    232232  double detReci = 1./det;
    233   Matrix res;
     233  RealSpaceMatrix res;
    234234  res.set(0,0,  detReci*RDET2(at(1,1),at(2,1),at(1,2),at(2,2)));    // A_11
    235235  res.set(1,0, -detReci*RDET2(at(1,0),at(2,0),at(1,2),at(2,2)));    // A_21
     
    244244}
    245245
    246 Matrix Matrix::transpose() const
     246RealSpaceMatrix RealSpaceMatrix::transpose() const
    247247{
    248248  std::cout << "const Matrix::transpose()." << std::endl;
    249   Matrix res = Matrix(const_cast<const MatrixContent *>(content)->transpose());
     249  RealSpaceMatrix res = RealSpaceMatrix(const_cast<const MatrixContent *>(content)->transpose());
    250250  return res;
    251251}
    252252
    253 Matrix &Matrix::transpose()
     253RealSpaceMatrix &RealSpaceMatrix::transpose()
    254254{
    255255  std::cout << "Matrix::transpose()." << std::endl;
     
    258258}
    259259
    260 Vector Matrix::transformToEigenbasis()
     260Vector RealSpaceMatrix::transformToEigenbasis()
    261261{
    262262  gsl_vector *eval = content->transformToEigenbasis();
     
    266266}
    267267
    268 const Matrix &Matrix::operator*=(const double factor)
     268const RealSpaceMatrix &RealSpaceMatrix::operator*=(const double factor)
    269269    {
    270270  *content *= factor;
     
    272272}
    273273
    274 const Matrix operator*(const double factor,const Matrix& mat)
    275 {
    276   Matrix tmp = mat;
     274const RealSpaceMatrix operator*(const double factor,const RealSpaceMatrix& mat)
     275{
     276  RealSpaceMatrix tmp = mat;
    277277  return tmp *= factor;
    278278}
    279279
    280 const Matrix operator*(const Matrix &mat,const double factor)
     280const RealSpaceMatrix operator*(const RealSpaceMatrix &mat,const double factor)
    281281{
    282282  return factor*mat;
    283283}
    284284
    285 bool Matrix::operator==(const Matrix &rhs) const
     285bool RealSpaceMatrix::operator==(const RealSpaceMatrix &rhs) const
    286286{
    287287  return (*content == *(rhs.content));
     
    292292 * \return allocated NDIM*NDIM array with the symmetric matrix
    293293 */
    294 Matrix ReturnFullMatrixforSymmetric(const double * const symm)
    295 {
    296   Matrix matrix;
     294RealSpaceMatrix ReturnFullMatrixforSymmetric(const double * const symm)
     295{
     296  RealSpaceMatrix matrix;
    297297  matrix.set(0,0, symm[0]);
    298298  matrix.set(1,0, symm[1]);
     
    307307};
    308308
    309 ostream &operator<<(ostream &ost,const Matrix &mat)
     309ostream &operator<<(ostream &ost,const RealSpaceMatrix &mat)
    310310{
    311311  for(int i = 0;i<NDIM;++i){
     
    320320}
    321321
    322 Vector operator*(const Matrix &mat,const Vector &vec)
     322Vector operator*(const RealSpaceMatrix &mat,const Vector &vec)
    323323{
    324324  return (*mat.content) * vec;
    325325}
    326326
    327 Vector &operator*=(Vector& lhs,const Matrix &mat)
     327Vector &operator*=(Vector& lhs,const RealSpaceMatrix &mat)
    328328{
    329329  lhs = mat*lhs;
Note: See TracChangeset for help on using the changeset viewer.