Changes in / [c7b39a:f0f1cc]
- Location:
- src
- Files:
-
- 4 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/RepeatBoxAction.cpp
rc7b39a rf0f1cc 13 13 #include "molecule.hpp" 14 14 #include "vector.hpp" 15 #include "Matrix.hpp"16 15 #include "verbose.hpp" 17 16 #include "World.hpp" … … 61 60 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 62 61 double * const cell_size = World::getInstance().getDomain(); 63 double *M_double = ReturnFullMatrixforSymmetric(cell_size); 64 Matrix M = Matrix(M_double); 65 delete[] M_double; 62 double *M = ReturnFullMatrixforSymmetric(cell_size); 66 63 Vector x,y; 67 64 int n[NDIM]; … … 121 118 } 122 119 } 120 delete(M); 123 121 delete dialog; 124 122 return Action::success; -
src/Makefile.am
rc7b39a rf0f1cc 30 30 atom_trajectoryparticleinfo.hpp 31 31 32 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \33 Exceptions/LinearDependenceException.cpp \34 Exceptions/MathException.cpp \35 Exceptions/NotInvertibleException.cpp \36 Exceptions/SkewException.cpp \37 Exceptions/ZeroVectorException.cpp38 39 EXCEPTIONHEADER = Exceptions/CustomException.hpp \40 Exceptions/LinearDependenceException.hpp \41 Exceptions/MathException.hpp \42 Exceptions/NotInvertibleException.hpp \43 Exceptions/SkewException.hpp \44 Exceptions/ZeroVectorException.hpp45 46 # TODO: Move Exceptionsource back down, when transition is done47 32 LINALGSOURCE = \ 48 ${EXCEPTIONSOURCE} \49 33 ${HELPERSOURCE} \ 50 34 gslmatrix.cpp \ 51 35 gslvector.cpp \ 52 36 linearsystemofequations.cpp \ 53 Matrix.cpp \54 37 Space.cpp \ 55 38 vector.cpp 56 57 39 58 LINALGHEADER = \ 59 ${EXCEPTIONHEADER} \ 60 gslmatrix.hpp \ 40 LINALGHEADER = gslmatrix.hpp \ 61 41 gslvector.hpp \ 62 42 linearsystemofequations.hpp \ 63 Matrix.hpp \64 43 Space.hpp \ 65 44 vector.hpp … … 139 118 Descriptors/MoleculeNameDescriptor.hpp \ 140 119 Descriptors/MoleculePtrDescriptor.hpp 141 142 #TODO: Exceptionsource should go here, when the transisition makes this possible 120 121 EXCEPTIONSOURCE = Exceptions/CustomException.cpp \ 122 Exceptions/LinearDependenceException.cpp \ 123 Exceptions/MathException.cpp \ 124 Exceptions/SkewException.cpp \ 125 Exceptions/ZeroVectorException.cpp 126 127 EXCEPTIONHEADER = Exceptions/CustomException.hpp \ 128 Exceptions/LinearDependenceException.hpp \ 129 Exceptions/MathException.hpp \ 130 Exceptions/SkewException.hpp \ 131 Exceptions/ZeroVectorException.hpp 132 143 133 SOURCE = \ 144 134 ${ANALYSISSOURCE} \ … … 149 139 ${DESCRIPTORSOURCE} \ 150 140 ${HELPERSOURCE} \ 141 ${EXCEPTIONSOURCE} \ 151 142 bond.cpp \ 152 143 bondgraph.cpp \ … … 194 185 ${PATTERNHEADER} \ 195 186 ${DESCRIPTORHEADER} \ 187 ${EXCEPTIONHEADER} \ 196 188 bond.hpp \ 197 189 bondgraph.hpp \ -
src/analysis_correlation.cpp
rc7b39a rf0f1cc 19 19 #include "triangleintersectionlist.hpp" 20 20 #include "vector.hpp" 21 #include "Matrix.hpp"22 21 #include "verbose.hpp" 23 22 #include "World.hpp" … … 136 135 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 137 136 if ((*MolWalker)->ActiveFlag) { 138 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 139 Matrix FullMatrix = Matrix(FullMatrix_double); 140 Matrix FullInverseMatrix = FullMatrix.invert(); 141 delete[](FullMatrix_double); 137 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 138 double * FullInverseMatrix = InverseMatrix(FullMatrix); 142 139 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 143 140 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; … … 179 176 } 180 177 } 178 delete[](FullMatrix); 179 delete[](FullInverseMatrix); 181 180 } 182 181 } … … 247 246 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 248 247 if ((*MolWalker)->ActiveFlag) { 249 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 250 Matrix FullMatrix = Matrix(FullMatrix_double); 251 Matrix FullInverseMatrix = FullMatrix.invert(); 252 delete[] FullMatrix_double; 248 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 249 double * FullInverseMatrix = InverseMatrix(FullMatrix); 253 250 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 254 251 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 270 267 } 271 268 } 269 delete[](FullMatrix); 270 delete[](FullInverseMatrix); 272 271 } 273 272 … … 353 352 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 354 353 if ((*MolWalker)->ActiveFlag) { 355 double * FullMatrix_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 356 Matrix FullMatrix = Matrix(FullMatrix_double); 357 Matrix FullInverseMatrix = FullMatrix.invert(); 358 delete[](FullMatrix_double); 354 double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 355 double * FullInverseMatrix = InverseMatrix(FullMatrix); 359 356 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 360 357 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 384 381 } 385 382 } 383 delete[](FullMatrix); 384 delete[](FullInverseMatrix); 386 385 } 387 386 -
src/boundary.cpp
rc7b39a rf0f1cc 22 22 #include "World.hpp" 23 23 #include "Plane.hpp" 24 #include "Matrix.hpp"25 24 26 25 #include<gsl/gsl_poly.h> … … 765 764 int N[NDIM]; 766 765 int n[NDIM]; 767 double *M_double = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 768 Matrix M = Matrix(M_double); 769 delete[](M_double); 770 Matrix Rotations; 771 Matrix MInverse = M.invert(); 766 double *M = ReturnFullMatrixforSymmetric(World::getInstance().getDomain()); 767 double Rotations[NDIM*NDIM]; 768 double *MInverse = InverseMatrix(M); 772 769 Vector AtomTranslations; 773 770 Vector FillerTranslations; … … 803 800 // calculate filler grid in [0,1]^3 804 801 FillerDistance = Vector(distance[0], distance[1], distance[2]); 805 FillerDistance. MatrixMultiplication(MInverse);802 FillerDistance.InverseMatrixMultiplication(M); 806 803 for(int i=0;i<NDIM;i++) 807 804 N[i] = (int) ceil(1./FillerDistance[i]); … … 838 835 } 839 836 840 Rotations .at(0,0)= cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));841 Rotations .at(0,1)= sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));842 Rotations .at(0,2)= cos(phi[1])*sin(phi[2]) ;843 Rotations .at(1,0)= - sin(phi[0])*cos(phi[1]) ;844 Rotations .at(1,1)= cos(phi[0])*cos(phi[1]) ;845 Rotations .at(1,2)= sin(phi[1]) ;846 Rotations .at(2,0)= - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));847 Rotations .at(2,1)= - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));848 Rotations .at(2,2)= cos(phi[1])*cos(phi[2]) ;837 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 838 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 839 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 840 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 841 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 842 Rotations[7] = sin(phi[1]) ; 843 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 844 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 845 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 849 846 } 850 847 … … 895 892 } 896 893 } 894 delete[](M); 895 delete[](MInverse); 897 896 898 897 return Filling; -
src/ellipsoid.cpp
rc7b39a rf0f1cc 21 21 #include "tesselation.hpp" 22 22 #include "vector.hpp" 23 #include "Matrix.hpp"24 23 #include "verbose.hpp" 25 24 … … 35 34 Vector helper, RefPoint; 36 35 double distance = -1.; 37 Matrix Matrix;36 double Matrix[NDIM*NDIM]; 38 37 double InverseLength[3]; 39 38 double psi,theta,phi; // euler angles in ZX'Z'' convention … … 52 51 theta = EllipsoidAngle[1]; 53 52 phi = EllipsoidAngle[2]; 54 Matrix .at(0,0)= cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);55 Matrix .at(1,0)= -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);56 Matrix .at(2,0)= sin(psi)*sin(theta);57 Matrix .at(0,1)= sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);58 Matrix .at(1,1)= cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);59 Matrix .at(2,1)= -cos(psi)*sin(theta);60 Matrix .at(0,2)= sin(theta)*sin(phi);61 Matrix .at(1,2)= sin(theta)*cos(phi);62 Matrix .at(2,2)= cos(theta);53 Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi); 54 Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi); 55 Matrix[2] = sin(psi)*sin(theta); 56 Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi); 57 Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi); 58 Matrix[5] = -cos(psi)*sin(theta); 59 Matrix[6] = sin(theta)*sin(phi); 60 Matrix[7] = sin(theta)*cos(phi); 61 Matrix[8] = cos(theta); 63 62 helper.MatrixMultiplication(Matrix); 64 63 helper.ScaleAll(InverseLength); … … 74 73 phi = -EllipsoidAngle[2]; 75 74 helper.ScaleAll(EllipsoidLength); 76 Matrix .at(0,0)= cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi);77 Matrix .at(1,0)= -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi);78 Matrix .at(2,0)= sin(psi)*sin(theta);79 Matrix .at(0,1)= sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi);80 Matrix .at(1,1)= cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi);81 Matrix .at(2,1)= -cos(psi)*sin(theta);82 Matrix .at(0,2)= sin(theta)*sin(phi);83 Matrix .at(1,2)= sin(theta)*cos(phi);84 Matrix .at(2,2)= cos(theta);75 Matrix[0] = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi); 76 Matrix[1] = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi); 77 Matrix[2] = sin(psi)*sin(theta); 78 Matrix[3] = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi); 79 Matrix[4] = cos(psi)*cos(theta)*cos(phi) - sin(psi)*sin(phi); 80 Matrix[5] = -cos(psi)*sin(theta); 81 Matrix[6] = sin(theta)*sin(phi); 82 Matrix[7] = sin(theta)*cos(phi); 83 Matrix[8] = cos(theta); 85 84 helper.MatrixMultiplication(Matrix); 86 85 //Log() << Verbose(4) << "Intersection is at " << helper << "." << endl; -
src/molecule.cpp
rc7b39a rf0f1cc 27 27 #include "tesselation.hpp" 28 28 #include "vector.hpp" 29 #include "Matrix.hpp"30 29 #include "World.hpp" 31 30 #include "Plane.hpp" … … 285 284 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 286 285 Vector InBondvector; // vector in direction of *Bond 287 Matrix matrix;286 double *matrix = NULL; 288 287 bond *Binder = NULL; 289 288 double * const cell_size = World::getInstance().getDomain(); … … 308 307 } // (signs are correct, was tested!) 309 308 } 310 double *matrix_double = ReturnFullMatrixforSymmetric(cell_size); 311 matrix = Matrix(matrix_double); 312 delete[](matrix_double); 309 matrix = ReturnFullMatrixforSymmetric(cell_size); 313 310 Orthovector1.MatrixMultiplication(matrix); 314 311 InBondvector -= Orthovector1; // subtract just the additional translation 312 delete[](matrix); 315 313 bondlength = InBondvector.Norm(); 316 314 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 543 541 break; 544 542 } 543 delete[](matrix); 545 544 546 545 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; -
src/molecule_fragmentation.cpp
rc7b39a rf0f1cc 22 22 #include "periodentafel.hpp" 23 23 #include "World.hpp" 24 #include "Matrix.hpp"25 24 26 25 /************************************* Functions for class molecule *********************************/ … … 1710 1709 atom *OtherWalker = NULL; 1711 1710 double * const cell_size = World::getInstance().getDomain(); 1712 double *matrix_double = ReturnFullMatrixforSymmetric(cell_size); 1713 Matrix matrix = Matrix(matrix_double); 1714 delete[](matrix_double); 1711 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1715 1712 enum Shading *ColorList = NULL; 1716 1713 double tmp; … … 1783 1780 delete(AtomStack); 1784 1781 delete[](ColorList); 1782 delete[](matrix); 1785 1783 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl); 1786 1784 }; -
src/molecule_geometry.cpp
rc7b39a rf0f1cc 19 19 #include "World.hpp" 20 20 #include "Plane.hpp" 21 #include "Matrix.hpp"22 21 #include <boost/foreach.hpp> 23 22 … … 155 154 156 155 const double *cell_size = World::getInstance().getDomain(); 157 double *M_double = ReturnFullMatrixforSymmetric(cell_size); 158 Matrix M = Matrix(M_double); 159 delete[](M_double); 156 double *M = ReturnFullMatrixforSymmetric(cell_size); 160 157 a->MatrixMultiplication(M); 158 delete[](M); 161 159 162 160 return a; … … 276 274 { 277 275 double * const cell_size = World::getInstance().getDomain(); 278 double *matrix_double = ReturnFullMatrixforSymmetric(cell_size); 279 Matrix matrix = Matrix(matrix_double); 280 delete[](matrix_double); 281 Matrix inversematrix = matrix.invert(); 276 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 277 double *inversematrix = InverseMatrix(matrix); 282 278 double tmp; 283 279 bool flag; … … 328 324 } 329 325 } while (!flag); 326 delete[](matrix); 327 delete[](inversematrix); 330 328 331 329 Center.Scale(1./static_cast<double>(getAtomCount())); … … 389 387 DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... "); 390 388 // the eigenvectors specify the transformation matrix 391 Matrix M = Matrix(evec->data); 392 ActOnAllVectors( &Vector::MatrixMultiplication, static_cast<const Matrix>(M)); 389 ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data ); 393 390 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 394 391 -
src/vector.cpp
rc7b39a rf0f1cc 8 8 9 9 #include "vector.hpp" 10 #include "Matrix.hpp"11 10 #include "verbose.hpp" 12 11 #include "World.hpp" 13 12 #include "Helpers/Assert.hpp" 14 13 #include "Helpers/fast_functions.hpp" 15 #include "Exceptions/MathException.hpp"16 14 17 15 #include <iostream> 18 #include <gsl/gsl_blas.h>19 20 16 21 17 using namespace std; … … 38 34 { 39 35 content = gsl_vector_alloc(NDIM); 40 gsl_vector_memcpy(content, src.content); 36 gsl_vector_set(content,0,src[0]); 37 gsl_vector_set(content,1,src[1]); 38 gsl_vector_set(content,2,src[2]); 41 39 } 42 40 … … 51 49 }; 52 50 53 Vector::Vector(gsl_vector *_content) :54 content(_content)55 {}56 57 51 /** 58 52 * Assignment operator … … 61 55 // check for self assignment 62 56 if(&src!=this){ 63 gsl_vector_memcpy(content, src.content); 57 gsl_vector_set(content,0,src[0]); 58 gsl_vector_set(content,1,src[1]); 59 gsl_vector_set(content,2,src[2]); 64 60 } 65 61 return *this; … … 105 101 double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const 106 102 { 107 double res = distance(y), tmp; 108 Matrix matrix; 103 double res = distance(y), tmp, matrix[NDIM*NDIM]; 109 104 Vector Shiftedy, TranslationVector; 110 105 int N[NDIM]; 111 matrix .at(0,0)= cell_size[0];112 matrix .at(1,0)= cell_size[1];113 matrix .at(2,0)= cell_size[3];114 matrix .at(0,1)= cell_size[1];115 matrix .at(1,1)= cell_size[2];116 matrix .at(2,1)= cell_size[4];117 matrix .at(0,2)= cell_size[3];118 matrix .at(1,2)= cell_size[4];119 matrix .at(2,2)= cell_size[5];106 matrix[0] = cell_size[0]; 107 matrix[1] = cell_size[1]; 108 matrix[2] = cell_size[3]; 109 matrix[3] = cell_size[1]; 110 matrix[4] = cell_size[2]; 111 matrix[5] = cell_size[4]; 112 matrix[6] = cell_size[3]; 113 matrix[7] = cell_size[4]; 114 matrix[8] = cell_size[5]; 120 115 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells 121 116 for (N[0]=-1;N[0]<=1;N[0]++) … … 143 138 double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const 144 139 { 145 double res = DistanceSquared(y), tmp; 146 Matrix matrix; 140 double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM]; 147 141 Vector Shiftedy, TranslationVector; 148 142 int N[NDIM]; 149 matrix .at(0,0)= cell_size[0];150 matrix .at(1,0)= cell_size[1];151 matrix .at(2,0)= cell_size[3];152 matrix .at(0,1)= cell_size[1];153 matrix .at(1,1)= cell_size[2];154 matrix .at(2,1)= cell_size[4];155 matrix .at(0,2)= cell_size[3];156 matrix .at(1,2)= cell_size[4];157 matrix .at(2,2)= cell_size[5];143 matrix[0] = cell_size[0]; 144 matrix[1] = cell_size[1]; 145 matrix[2] = cell_size[3]; 146 matrix[3] = cell_size[1]; 147 matrix[4] = cell_size[2]; 148 matrix[5] = cell_size[4]; 149 matrix[6] = cell_size[3]; 150 matrix[7] = cell_size[4]; 151 matrix[8] = cell_size[5]; 158 152 // in order to check the periodic distance, translate one of the vectors into each of the 27 neighbouring cells 159 153 for (N[0]=-1;N[0]<=1;N[0]++) … … 178 172 * Tries to translate a vector into each adjacent neighbouring cell. 179 173 */ 180 void Vector::KeepPeriodic(const double * const _matrix) 181 { 182 Matrix matrix = Matrix(_matrix); 174 void Vector::KeepPeriodic(const double * const matrix) 175 { 183 176 // int N[NDIM]; 184 177 // bool flag = false; … … 188 181 // Output(out); 189 182 // Log() << Verbose(0) << endl; 190 MatrixMultiplication(matrix.invert());183 InverseMatrixMultiplication(matrix); 191 184 for(int i=NDIM;i--;) { // correct periodically 192 185 if (at(i) < 0) { // get every coefficient into the interval [0,1) … … 210 203 { 211 204 double res = 0.; 212 gsl_blas_ddot(content, y.content, &res); 205 for (int i=NDIM;i--;) 206 res += at(i)*y[i]; 213 207 return (res); 214 208 }; … … 467 461 }; 468 462 469 Vector &Vector::operator*=(const Matrix &mat){470 (*this) = mat*(*this);471 return *this;472 }473 474 Vector operator*(const Matrix &mat,const Vector &vec){475 gsl_vector *res = gsl_vector_calloc(NDIM);476 gsl_blas_dgemv( CblasNoTrans, 1.0, mat.content, vec.content, 0.0, res);477 return Vector(res);478 }479 480 481 463 /** Factors given vector \a a times \a m. 482 464 * \param a vector … … 526 508 void Vector::Scale(const double factor) 527 509 { 528 gsl_vector_scale(content,factor); 510 for (int i=NDIM;i--;) 511 at(i) *= factor; 529 512 }; 530 513 … … 533 516 * \param *Minv inverse matrix 534 517 */ 535 void Vector::WrapPeriodically(const double * const _M, const double * const _Minv) 536 { 537 Matrix M = Matrix(_M); 538 Matrix Minv = Matrix(_Minv); 518 void Vector::WrapPeriodically(const double * const M, const double * const Minv) 519 { 539 520 MatrixMultiplication(Minv); 540 521 // truncate to [0,1] for each axis … … 569 550 * \param *matrix NDIM_NDIM array 570 551 */ 571 void Vector::MatrixMultiplication(const Matrix &M) 572 { 573 (*this) *= M; 552 void Vector::MatrixMultiplication(const double * const M) 553 { 554 Vector tmp; 555 // do the matrix multiplication 556 for(int i=NDIM;i--;) 557 tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2); 558 559 (*this) = tmp; 574 560 }; 575 561 … … 579 565 bool Vector::InverseMatrixMultiplication(const double * const A) 580 566 { 581 /*582 567 double B[NDIM*NDIM]; 583 568 double detA = RDET3(A); … … 601 586 return true; 602 587 } else { 603 return false;604 }605 */606 Matrix mat = Matrix(A);607 try{608 (*this) *= mat.invert();609 return true;610 }611 catch(MathException &excpt){612 588 return false; 613 589 } … … 703 679 void Vector::AddVector(const Vector &y) 704 680 { 705 gsl_vector_add(content, y.content); 681 for(int i=NDIM;i--;) 682 at(i) += y[i]; 706 683 } 707 684 … … 711 688 void Vector::SubtractVector(const Vector &y) 712 689 { 713 gsl_vector_sub(content, y.content); 690 for(int i=NDIM;i--;) 691 at(i) -= y[i]; 714 692 } 715 693 -
src/vector.hpp
rc7b39a rf0f1cc 24 24 25 25 class Vector; 26 class Matrix;27 26 28 27 typedef std::vector<Vector> pointset; … … 32 31 */ 33 32 class Vector : public Space{ 34 friend Vector operator*(const Matrix&,const Vector&);35 33 public: 34 36 35 Vector(); 37 36 Vector(const double x1, const double x2, const double x3); … … 60 59 void ScaleAll(const double *factor); 61 60 void Scale(const double factor); 62 void MatrixMultiplication(const Matrix &M);61 void MatrixMultiplication(const double * const M); 63 62 bool InverseMatrixMultiplication(const double * const M); 64 63 void KeepPeriodic(const double * const matrix); … … 97 96 Vector const operator+(const Vector& b) const; 98 97 Vector const operator-(const Vector& b) const; 99 Vector& operator*=(const Matrix&);100 98 101 99 // Methods inherited from Space … … 106 104 107 105 private: 108 Vector(gsl_vector *);109 106 gsl_vector *content; 110 107 … … 121 118 Vector const operator*(const Vector& a, const double m); 122 119 Vector const operator*(const double m, const Vector& a); 123 Vector operator*(const Matrix&,const Vector&);124 125 120 126 121 #endif /*VECTOR_HPP_*/
Note:
See TracChangeset
for help on using the changeset viewer.