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