Changes in / [589112:6e06bd]
- Location:
- src
- Files:
-
- 11 added
- 10 deleted
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r589112 r6e06bd 22 22 #include "Helpers/Log.hpp" 23 23 #include "Helpers/Verbose.hpp" 24 #include "LinearAlgebra/ Matrix.hpp"24 #include "LinearAlgebra/RealSpaceMatrix.hpp" 25 25 #include "LinearAlgebra/Vector.hpp" 26 26 #include "element.hpp" … … 40 40 /** =========== define the function ====================== */ 41 41 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 42 Matrix InertiaTensor;42 RealSpaceMatrix InertiaTensor; 43 43 44 44 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); … … 48 48 49 49 // reset inertia tensor 50 InertiaTensor. zero();50 InertiaTensor.setZero(); 51 51 52 52 // sum up inertia tensor -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r589112 r6e06bd 23 23 #include "Helpers/Verbose.hpp" 24 24 #include "LinearAlgebra/Line.hpp" 25 #include "LinearAlgebra/ Matrix.hpp"25 #include "LinearAlgebra/RealSpaceMatrix.hpp" 26 26 #include "LinearAlgebra/Vector.hpp" 27 27 #include "element.hpp" … … 50 50 mol = iter->second; 51 51 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 52 Matrix InertiaTensor;52 RealSpaceMatrix InertiaTensor; 53 53 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(); 54 54 55 55 // reset inertia tensor 56 InertiaTensor. zero();56 InertiaTensor.setZero(); 57 57 58 58 // sum up inertia tensor … … 105 105 // summing anew for debugging (resulting matrix has to be diagonal!) 106 106 // reset inertia tensor 107 InertiaTensor. zero();107 InertiaTensor.setZero(); 108 108 109 109 // sum up inertia tensor -
src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp
r589112 r6e06bd 25 25 #include "Helpers/Log.hpp" 26 26 #include "Helpers/Verbose.hpp" 27 #include "LinearAlgebra/ Matrix.hpp"27 #include "LinearAlgebra/RealSpaceMatrix.hpp" 28 28 #include "LinearAlgebra/Vector.hpp" 29 29 #include "Shapes/BaseShapes.hpp" … … 45 45 Action::state_ptr SelectionAllAtomsInsideCuboidAction::performCall() { 46 46 std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms(); 47 Matrix RotationMatrix;47 RealSpaceMatrix RotationMatrix; 48 48 49 49 // obtain information 50 50 getParametersfromValueStorage(); 51 51 52 RotationMatrix. rotation(params.Xangle, params.Yangle, params.Zangle);52 RotationMatrix.setRotation(params.Xangle, params.Yangle, params.Zangle); 53 53 54 54 DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "." << endl); … … 70 70 Action::state_ptr SelectionAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){ 71 71 SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get()); 72 Matrix RotationMatrix;72 RealSpaceMatrix RotationMatrix; 73 73 74 RotationMatrix. rotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);74 RotationMatrix.setRotation(state->params.Xangle, state->params.Yangle, state->params.Zangle); 75 75 Shape s = translate(transform(stretch(Cuboid(),state->params.extension),RotationMatrix),state->params.position); 76 76 World::getInstance().selectAllAtoms(AtomByShape(s)); -
src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp
r589112 r6e06bd 25 25 #include "Helpers/Log.hpp" 26 26 #include "Helpers/Verbose.hpp" 27 #include "LinearAlgebra/ Matrix.hpp"27 #include "LinearAlgebra/RealSpaceMatrix.hpp" 28 28 #include "LinearAlgebra/Vector.hpp" 29 29 #include "Shapes/BaseShapes.hpp" … … 45 45 Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performCall() { 46 46 std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms(); 47 Matrix RotationMatrix;47 RealSpaceMatrix RotationMatrix; 48 48 49 49 // obtain information 50 50 getParametersfromValueStorage(); 51 RotationMatrix. rotation(params.Xangle, params.Yangle, params.Zangle);51 RotationMatrix.setRotation(params.Xangle, params.Yangle, params.Zangle); 52 52 53 53 DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "." << endl); … … 70 70 Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){ 71 71 SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get()); 72 Matrix RotationMatrix;72 RealSpaceMatrix RotationMatrix; 73 73 74 RotationMatrix. rotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);74 RotationMatrix.setRotation(state->params.Xangle, state->params.Yangle, state->params.Zangle); 75 75 Shape s = translate(transform(stretch(Cuboid(),state->params.extension),RotationMatrix),state->params.position); 76 76 World::getInstance().unselectAllAtoms(AtomByShape(s)); -
src/Actions/ValueStorage.cpp
r589112 r6e06bd 31 31 #include "Helpers/Verbose.hpp" 32 32 #include "LinearAlgebra/BoxVector.hpp" 33 #include "LinearAlgebra/ Matrix.hpp"33 #include "LinearAlgebra/RealSpaceMatrix.hpp" 34 34 #include "LinearAlgebra/Vector.hpp" 35 35 #include "atom.hpp" … … 95 95 96 96 void ValueStorage::queryCurrentValue(const char * name, class Box &_T) { 97 Matrix M;97 RealSpaceMatrix M; 98 98 double tmp; 99 99 if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { … … 254 254 void ValueStorage::setCurrentValue(const char * name, class Box &_T) 255 255 { 256 const Matrix &M = _T.getM();256 const RealSpaceMatrix &M = _T.getM(); 257 257 if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) { 258 258 std::ostringstream stream; -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r589112 r6e06bd 24 24 #include "LinearAlgebra/Vector.hpp" 25 25 #include "World.hpp" 26 #include "LinearAlgebra/ Matrix.hpp"26 #include "LinearAlgebra/RealSpaceMatrix.hpp" 27 27 28 28 #include <iostream> … … 59 59 } 60 60 // set new box size 61 Matrix domain;61 RealSpaceMatrix domain; 62 62 for (int i=0;i<NDIM;i++) { 63 63 double tmp = Max[i]-Min[i]; -
src/Actions/WorldAction/ChangeBoxAction.cpp
r589112 r6e06bd 24 24 #include "World.hpp" 25 25 #include "Box.hpp" 26 #include "LinearAlgebra/ Matrix.hpp"26 #include "LinearAlgebra/RealSpaceMatrix.hpp" 27 27 28 28 #include <iostream> -
src/Actions/WorldAction/RepeatBoxAction.cpp
r589112 r6e06bd 25 25 #include "molecule.hpp" 26 26 #include "LinearAlgebra/Vector.hpp" 27 #include "LinearAlgebra/ Matrix.hpp"27 #include "LinearAlgebra/RealSpaceMatrix.hpp" 28 28 #include "Helpers/Verbose.hpp" 29 29 #include "World.hpp" … … 63 63 64 64 (cout << "Repeating box " << params.Repeater << " times for (x,y,z) axis." << endl); 65 Matrix M = World::getInstance().getDomain().getM();66 Matrix newM = M;65 RealSpaceMatrix M = World::getInstance().getDomain().getM(); 66 RealSpaceMatrix newM = M; 67 67 Vector x,y; 68 68 int n[NDIM]; 69 Matrix repMat;69 RealSpaceMatrix repMat; 70 70 for (int axis = 0; axis < NDIM; axis++) { 71 71 params.Repeater[axis] = floor(params.Repeater[axis]); -
src/Actions/WorldAction/ScaleBoxAction.cpp
r589112 r6e06bd 26 26 #include "World.hpp" 27 27 #include "Box.hpp" 28 #include "LinearAlgebra/ Matrix.hpp"28 #include "LinearAlgebra/RealSpaceMatrix.hpp" 29 29 30 30 #include <iostream> … … 53 53 } 54 54 55 Matrix M = World::getInstance().getDomain().getM();56 Matrix scale;55 RealSpaceMatrix M = World::getInstance().getDomain().getM(); 56 RealSpaceMatrix scale; 57 57 58 58 for (int i=0;i<NDIM;i++) { -
src/Box.cpp
r589112 r6e06bd 26 26 #include <cstdlib> 27 27 28 #include "LinearAlgebra/ Matrix.hpp"28 #include "LinearAlgebra/RealSpaceMatrix.hpp" 29 29 #include "LinearAlgebra/Vector.hpp" 30 30 #include "LinearAlgebra/Plane.hpp" … … 38 38 Box::Box() 39 39 { 40 M= new Matrix();41 M-> one();42 Minv = new Matrix();43 Minv-> one();40 M= new RealSpaceMatrix(); 41 M->setIdentity(); 42 Minv = new RealSpaceMatrix(); 43 Minv->setIdentity(); 44 44 conditions.resize(3); 45 45 conditions[0] = conditions[1] = conditions[2] = Wrap; … … 47 47 48 48 Box::Box(const Box& src){ 49 M=new Matrix(*src.M);50 Minv = new Matrix(*src.Minv);49 M=new RealSpaceMatrix(*src.M); 50 Minv = new RealSpaceMatrix(*src.Minv); 51 51 conditions = src.conditions; 52 52 } … … 58 58 } 59 59 60 const Matrix &Box::getM() const{60 const RealSpaceMatrix &Box::getM() const{ 61 61 return *M; 62 62 } 63 const Matrix &Box::getMinv() const{63 const RealSpaceMatrix &Box::getMinv() const{ 64 64 return *Minv; 65 65 } 66 66 67 void Box::setM( Matrix _M){67 void Box::setM(RealSpaceMatrix _M){ 68 68 ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible"); 69 69 *M =_M; … … 253 253 void Box::setCuboid(const Vector &endpoint){ 254 254 ASSERT(endpoint[0]>0 && endpoint[1]>0 && endpoint[2]>0,"Vector does not define a full cuboid"); 255 M-> one();255 M->setIdentity(); 256 256 M->diagonal()=endpoint; 257 257 Vector &dinv = Minv->diagonal(); … … 264 264 delete M; 265 265 delete Minv; 266 M = new Matrix(*src.M);267 Minv = new Matrix(*src.Minv);266 M = new RealSpaceMatrix(*src.M); 267 Minv = new RealSpaceMatrix(*src.Minv); 268 268 conditions = src.conditions; 269 269 } … … 271 271 } 272 272 273 Box &Box::operator=(const Matrix &mat){273 Box &Box::operator=(const RealSpaceMatrix &mat){ 274 274 setM(mat); 275 275 return *this; -
src/Box.hpp
r589112 r6e06bd 9 9 #define BOX_HPP_ 10 10 11 class Matrix;11 class RealSpaceMatrix; 12 12 class Vector; 13 13 class Shape; … … 44 44 * Get the matrix describing the form of the parallelepiped 45 45 */ 46 const Matrix &getM() const;46 const RealSpaceMatrix &getM() const; 47 47 48 48 /** 49 49 * Get the inverse of the matrix M (see above). 50 50 */ 51 const Matrix &getMinv() const;51 const RealSpaceMatrix &getMinv() const; 52 52 53 53 /** 54 54 * Set the form of the parallelepiped. 55 55 */ 56 void setM( Matrix);56 void setM(RealSpaceMatrix); 57 57 58 58 Box &operator=(const Box&); 59 Box &operator=(const Matrix&);59 Box &operator=(const RealSpaceMatrix&); 60 60 61 61 /** … … 110 110 private: 111 111 Conditions_t conditions; 112 Matrix *M; //!< Defines the layout of the box113 Matrix *Minv; //!< Inverse of M to avoid recomputation112 RealSpaceMatrix *M; //!< Defines the layout of the box 113 RealSpaceMatrix *Minv; //!< Inverse of M to avoid recomputation 114 114 }; 115 115 -
src/Helpers/Assert.hpp
r589112 r6e06bd 14 14 #include<vector> 15 15 #include<map> 16 17 #include "Helpers/toString.hpp" 16 18 17 19 /** … … 184 186 * This can be done in the following way: 185 187 * @code 186 * ASSERT(!i,"i was not zero but "+ std::string(i)+"after incrementing");187 * @endcode 188 * Note that this works because std::string() in the middle requires the const char arrays on both ends189 * to be converted to string and eventually, the whole text is again cast to const char * form.188 * ASSERT(!i,"i was not zero but "+toString(i)+"after incrementing"); 189 * @endcode 190 * Note that this works because of the template function toString() (in src/Helpers/toString.hpp) that 191 * uses stringstreams to convert any value to std::string if the respective operator<< is implemented. 190 192 * <li> <H4> ASSERT() is broken. When I abort the program it says something about an 191 193 * "Illegal instruction"</H4> -
src/LinearAlgebra/Line.cpp
r589112 r6e06bd 28 28 #include "Helpers/Log.hpp" 29 29 #include "Helpers/Verbose.hpp" 30 #include "LinearAlgebra/ gslmatrix.hpp"30 #include "LinearAlgebra/MatrixContent.hpp" 31 31 #include "Helpers/Info.hpp" 32 32 #include "Exceptions/LinearDependenceException.hpp" … … 116 116 Vector res; 117 117 118 auto_ptr< GSLMatrix> M = auto_ptr<GSLMatrix>(new GSLMatrix(4,4));119 120 M-> SetAll(1.);118 auto_ptr<MatrixContent> M = auto_ptr<MatrixContent>(new MatrixContent(4,4)); 119 120 M->setValue(1.); 121 121 for (int i=0;i<3;i++) { 122 M-> Set(0, i, Line1a[i]);123 M-> Set(1, i, Line1b[i]);124 M-> Set(2, i, Line2a[i]);125 M-> Set(3, i, Line2b[i]);122 M->set(0, i, Line1a[i]); 123 M->set(1, i, Line1b[i]); 124 M->set(2, i, Line2a[i]); 125 M->set(3, i, Line2b[i]); 126 126 } 127 127 -
src/LinearAlgebra/Makefile.am
r589112 r6e06bd 12 12 ${HELPERSOURCE} \ 13 13 BoxVector.cpp \ 14 gslmatrix.cpp \15 14 gslvector.cpp \ 16 15 Line.cpp \ … … 18 17 LineSegmentSet.cpp \ 19 18 linearsystemofequations.cpp \ 20 Matrix .cpp \19 MatrixContent.cpp \ 21 20 Plane.cpp \ 21 RealSpaceMatrix.cpp \ 22 22 Space.cpp \ 23 23 vector_ops.cpp \ 24 24 Vector.cpp \ 25 VectorContent.cpp \ 25 26 VectorInterface.cpp 26 27 27 28 LINALGHEADER = \ 28 29 BoxVector.hpp \ 29 gslmatrix.hpp \30 30 gslvector.hpp \ 31 31 Line.hpp \ … … 33 33 LineSegmentSet.hpp \ 34 34 linearsystemofequations.hpp \ 35 Matrix.hpp \ 35 MatrixContent.hpp \ 36 RealSpaceMatrix.hpp \ 36 37 Plane.hpp \ 37 38 Space.hpp \ 38 39 vector_ops.hpp \ 39 40 Vector.hpp \ 41 VectorContent.hpp \ 40 42 VectorInterface.hpp 41 43 -
src/LinearAlgebra/MatrixContent.hpp
r589112 r6e06bd 9 9 #define MATRIXCONTENT_HPP_ 10 10 11 /** 12 * !file 13 * The way GSL works does not allow for forward definitions of the structures. 14 * Because of this the pointer to the gsl_matrix struct is wrapped inside another 15 * (dumb) object that allows for forward definitions. All methods of this class 16 * are empty, to allow for a maximum of flexibility. 11 /** MatrixContent is a wrapper for gsl_matrix. 12 * 13 * The GNU Scientific Library contaisn some very well written routines for 14 * linear algebra problems. However, it's syntax is C and hence it does not 15 * lend itself to readable written code, i.e. C = A * B, where A, B, and C 16 * are all matrices. Writing code this way is very convenient, concise and 17 * also in the same manner as one would type in MatLab. 18 * However, with C++ and its feature to overload functions and its operator 19 * functions such syntax is easy to create. 20 * 21 * Hence, this class is a C++ wrapper to gsl_matrix. There already some other 22 * libraries, however they fall short for the following reasons: 23 * -# gslwrap: not very well written and uses floats instead of doubles 24 * -# gslcpp: last change is from 2007 and only very few commits 25 * -# o2scl: basically, the same functionality as gsl only written in C++, 26 * however it uses GPLv3 license which is inconvenient for MoleCuilder. 27 * 28 * <h1>Howto use MatrixContent</h1> 29 * 30 * One should not use MatrixContent directly but either have it as a member 31 * variable in a specialized class or inherit from it. 32 * 17 33 */ 18 34 19 35 #include <gsl/gsl_matrix.h> 20 36 21 struct MatrixContent{ 37 class Vector; 38 39 class MatrixContent 40 { 41 friend Vector operator*(const MatrixContent &mat,const Vector &vec); 42 friend class RealSpaceMatrix; 43 friend class LinearSystemOfEquations; 44 45 friend class MatrixContentTest; 46 friend class MatrixContentSymmetricTest; 47 public: 48 MatrixContent(size_t rows, size_t columns); 49 MatrixContent(size_t rows, size_t columns, const double *src); 50 MatrixContent(gsl_matrix *&src); 51 MatrixContent(const MatrixContent &src); 52 MatrixContent(const MatrixContent *src); 53 ~MatrixContent(); 54 55 // Accessing 56 double &at(size_t i, size_t j); 57 const double at(size_t i, size_t j) const; 58 void set(size_t i, size_t j, const double value); 59 60 // Initializing 61 void setFromDoubleArray(double * x); 62 void setIdentity(); 63 void setValue(double _value); 64 void setZero(); 65 66 // Exchanging elements 67 bool SwapRows(size_t i, size_t j); 68 bool SwapColumns(size_t i, size_t j); 69 bool SwapRowColumn(size_t i, size_t j); 70 71 // Transformations 72 MatrixContent transpose() const; 73 MatrixContent &transpose(); 74 gsl_vector* transformToEigenbasis(); 75 76 // Properties 77 bool IsNull() const; 78 bool IsPositive() const; 79 bool IsNegative() const; 80 bool IsNonNegative() const; 81 bool IsPositiveDefinite() const; 82 double Determinant() const; 83 84 // Operators 85 MatrixContent &operator=(const MatrixContent &src); 86 const MatrixContent &operator+=(const MatrixContent &rhs); 87 const MatrixContent &operator-=(const MatrixContent &rhs); 88 const MatrixContent &operator*=(const MatrixContent &rhs); 89 const MatrixContent operator*(const MatrixContent &rhs) const; 90 const MatrixContent &operator*=(const double factor); 91 bool operator==(const MatrixContent &rhs) const; 92 93 protected: 94 double *Pointer(size_t m, size_t n); 95 const double *const_Pointer(size_t m, size_t n) const; 96 97 private: 22 98 gsl_matrix * content; 99 const size_t rows; // store for internal purposes 100 const size_t columns; // store for internal purposes 23 101 }; 24 102 103 const MatrixContent operator*(const double factor,const MatrixContent& mat); 104 const MatrixContent operator*(const MatrixContent &mat,const double factor); 105 Vector operator*(const MatrixContent &mat,const Vector &vec); 106 25 107 #endif /* MATRIXCONTENT_HPP_ */ -
src/LinearAlgebra/Vector.cpp
r589112 r6e06bd 41 41 Vector::Vector() 42 42 { 43 content = new VectorContent(); 44 }; 45 46 /** 47 * Copy constructor 48 */ 49 43 content = new VectorContent((size_t) NDIM); 44 }; 45 46 /** Copy constructor. 47 * \param &src source Vector reference 48 */ 50 49 Vector::Vector(const Vector& src) 51 50 { 52 content = new VectorContent(); 53 gsl_vector_memcpy(content->content, src.content->content); 51 content = new VectorContent(*(src.content)); 54 52 } 55 53 56 54 /** Constructor of class vector. 55 * \param x1 first component 56 * \param x2 second component 57 * \param x3 third component 57 58 */ 58 59 Vector::Vector(const double x1, const double x2, const double x3) 59 60 { 60 content = new VectorContent( );61 gsl_vector_set(content->content,0,x1);62 gsl_vector_set(content->content,1,x2);63 gsl_vector_set(content->content,2,x3);61 content = new VectorContent((size_t) NDIM); 62 content->at(0) = x1; 63 content->at(1) = x2; 64 content->at(2) = x3; 64 65 }; 65 66 66 67 /** Constructor of class vector. 68 * \param x[3] three values to initialize Vector with 67 69 */ 68 70 Vector::Vector(const double x[3]) 69 71 { 70 content = new VectorContent(); 71 gsl_vector_set(content->content,0,x[0]); 72 gsl_vector_set(content->content,1,x[1]); 73 gsl_vector_set(content->content,2,x[2]); 74 }; 75 76 Vector::Vector(VectorContent *_content) : 77 content(_content) 78 {} 79 80 /** 81 * Assignment operator 72 content = new VectorContent((size_t) NDIM); 73 for (size_t i = NDIM; i--; ) 74 content->at(i) = x[i]; 75 }; 76 77 /** Copy constructor of class vector from VectorContent. 78 * \note This is destructive, i.e. we take over _content. 79 */ 80 Vector::Vector(VectorContent *&_content) : 81 content(_content) 82 { 83 _content = NULL; 84 } 85 86 /** Copy constructor of class vector from VectorContent. 87 * \note This is non-destructive, i.e. _content is copied. 88 */ 89 Vector::Vector(VectorContent &_content) 90 { 91 content = new VectorContent(_content); 92 } 93 94 /** Assignment operator. 95 * \param &src source vector to assign \a *this to 96 * \return reference to \a *this 82 97 */ 83 98 Vector& Vector::operator=(const Vector& src){ 84 99 // check for self assignment 85 100 if(&src!=this){ 86 gsl_vector_memcpy(content->content, src.content->content);101 *content = *(src.content); 87 102 } 88 103 return *this; … … 90 105 91 106 /** Desctructor of class vector. 107 * Vector::content is deleted. 92 108 */ 93 109 Vector::~Vector() { -
src/LinearAlgebra/Vector.hpp
r589112 r6e06bd 22 22 23 23 class Vector; 24 class Matrix; 24 class RealSpaceMatrix; 25 class MatrixContent; 25 26 struct VectorContent; 26 27 … … 31 32 */ 32 33 class Vector : public Space{ 33 friend Vector operator*(const Matrix &,const Vector&);34 friend class Matrix;34 friend Vector operator*(const MatrixContent&,const Vector&); 35 friend class RealSpaceMatrix; // needs access to Vector(VectorContent*&) due to views 35 36 public: 36 37 Vector(); … … 103 104 104 105 private: 105 Vector(VectorContent *); 106 explicit Vector(VectorContent *&); 107 explicit Vector(VectorContent &_content); 106 108 VectorContent *content; 107 109 -
src/LinearAlgebra/VectorContent.hpp
r589112 r6e06bd 18 18 */ 19 19 20 #include <iosfwd> 21 20 22 #include <gsl/gsl_vector.h> 21 23 24 class Vector; 25 26 /** Dummy structure to create a unique signature. 27 * 28 */ 22 29 struct BaseCase{}; 23 30 24 struct VectorContent{ 25 VectorContent(){ 26 content = gsl_vector_calloc (NDIM); 27 } 28 VectorContent(BaseCase){ 31 class VectorContent{ 32 friend std::ostream & operator<< (std::ostream& ost, const VectorContent &m); 33 friend VectorContent const operator*(const VectorContent& a, const double m); 34 friend VectorContent const operator*(const double m, const VectorContent& a); 35 friend VectorContent const operator+(const VectorContent& a, const VectorContent& b); 36 friend VectorContent const operator-(const VectorContent& a, const VectorContent& b); 29 37 30 } 31 virtual ~VectorContent(){ 32 if(content){ 33 gsl_vector_free(content); 34 content = 0; 35 } 36 } 38 public: 39 explicit VectorContent(size_t _dim); 40 VectorContent(BaseCase); 41 VectorContent(const VectorContent * const src); 42 VectorContent(const VectorContent & src); 43 virtual ~VectorContent(); 44 45 // Accessing 46 double &at(size_t m); 47 const double at(size_t m) const; 48 double & operator[](size_t i); 49 const double operator[](size_t i) const; 50 double *Pointer(size_t m) const; 51 const double *const_Pointer(size_t m) const; 52 53 // Assignment operator 54 VectorContent &operator=(const VectorContent& src); 55 56 // Initializing 57 void setFromDoubleArray(double * x); 58 void setFromVector(Vector &v); 59 void setValue(double x); 60 void setZero(); 61 int setBasis(size_t m); 62 63 // Exchanging elements 64 int SwapElements(size_t i, size_t j); 65 int Reverse(); 66 67 // checking state 68 bool IsZero() const; 69 bool IsOne() const; 70 71 // properties 72 bool IsNormalTo(const Vector &normal) const; 73 bool IsEqualTo(const Vector &a) const; 74 75 // properties relative to another VectorContent 76 double DistanceSquared(const VectorContent &y) const; 77 double ScalarProduct(const VectorContent &y) const; 78 double Angle(const VectorContent &y) const; 79 80 // operators 81 bool operator==(const VectorContent& b) const; 82 const VectorContent& operator+=(const VectorContent& b); 83 const VectorContent& operator-=(const VectorContent& b); 84 const VectorContent& operator*=(const double m); 85 86 size_t dimension; 37 87 gsl_vector *content; 88 private: 38 89 }; 39 90 40 struct VectorViewContent : public VectorContent{ 91 std::ostream & operator << (std::ostream& ost, const VectorContent &m); 92 VectorContent const operator*(const VectorContent& a, const double m); 93 VectorContent const operator*(const double m, const VectorContent& a); 94 VectorContent const operator+(const VectorContent& a, const VectorContent& b); 95 VectorContent const operator-(const VectorContent& a, const VectorContent& b); 96 97 /** Vector view. 98 * Extension of VectorContent to contain not a gsl_vector but only a view on a 99 * gsl_vector (or row/column in a gsl_matrix). 100 * 101 * We need the above BaseCase here: 102 * content, i.e. the gsl_vector, must not be allocated, as it is just a view 103 * with an internal gsl_vector_view. Hence, BaseCase is just dummy class to 104 * give the constructor a unique signature. 105 */ 106 struct VectorViewContent : public VectorContent 107 { 41 108 VectorViewContent(gsl_vector_view _view) : 42 109 VectorContent(BaseCase()), 43 110 view(_view) 44 111 { 112 dimension = _view.vector.size; 45 113 content=&view.vector; 46 114 } 47 virtual~VectorViewContent(){115 ~VectorViewContent(){ 48 116 content=0; 49 117 } -
src/LinearAlgebra/linearsystemofequations.cpp
r589112 r6e06bd 21 21 22 22 #include "defs.hpp" 23 #include "LinearAlgebra/ gslmatrix.hpp"24 #include "LinearAlgebra/ gslvector.hpp"23 #include "LinearAlgebra/MatrixContent.hpp" 24 #include "LinearAlgebra/VectorContent.hpp" 25 25 #include "LinearAlgebra/linearsystemofequations.hpp" 26 #include "Helpers/Assert.hpp" 26 27 #include "Helpers/logger.hpp" 27 28 #include "LinearAlgebra/Vector.hpp" 28 29 29 #include <cassert>30 30 #include <gsl/gsl_permutation.h> 31 31 … … 37 37 LinearSystemOfEquations::LinearSystemOfEquations(int m, int n) : rows(m), columns(n), IsSymmetric(false) 38 38 { 39 A = new GSLMatrix(m, n);40 b = new GSLVector(m);41 x = new GSLVector(n);39 A = new MatrixContent(m, n); 40 b = new VectorContent(m); 41 x = new VectorContent(n); 42 42 }; 43 43 … … 58 58 bool LinearSystemOfEquations::SetSymmetric(bool symmetric) 59 59 { 60 assert (rows == columns &&"Rows and columns don't have equal size! Setting symmetric not possible.");60 ASSERT (rows == columns, "Rows and columns don't have equal size! Setting symmetric not possible."); 61 61 return (IsSymmetric = symmetric); 62 62 }; … … 67 67 void LinearSystemOfEquations::Setb(Vector *x) 68 68 { 69 assert ( columns == NDIM &&"Vector class is always three-dimensional, unlike this LEqS!");70 b-> SetFromVector(*x);69 ASSERT ( columns == NDIM, "Vector class is always three-dimensional, unlike this LEqS!"); 70 b->setFromVector(*x); 71 71 }; 72 72 … … 76 76 void LinearSystemOfEquations::Setb(double *x) 77 77 { 78 b-> SetFromDoubleArray(x);78 b->setFromDoubleArray(x); 79 79 }; 80 80 … … 85 85 void LinearSystemOfEquations::SetA(double *x) 86 86 { 87 A-> SetFromDoubleArray(x);87 A->setFromDoubleArray(x); 88 88 }; 89 89 … … 98 98 // copy solution 99 99 for (size_t i=0;i<x->dimension;i++) { 100 array[i] = x-> Get(i);100 array[i] = x->at(i); 101 101 } 102 102 return status; … … 109 109 bool LinearSystemOfEquations::GetSolutionAsVector(Vector &v) 110 110 { 111 assert(rows == NDIM &&"Solution can only be returned as vector if number of columns is NDIM.");111 ASSERT (rows == NDIM, "Solution can only be returned as vector if number of columns is NDIM."); 112 112 bool status = Solve(); 113 113 114 114 // copy solution 115 115 for (size_t i=0;i<x->dimension;i++) 116 v[i] = x-> Get(i);116 v[i] = x->at(i); 117 117 return status; 118 118 }; … … 129 129 if (IsSymmetric) { // use LU 130 130 gsl_permutation * p = gsl_permutation_alloc (x->dimension); 131 gsl_linalg_LU_decomp (A-> matrix, p, &s);132 gsl_linalg_LU_solve (A-> matrix, p, b->vector, x->vector);131 gsl_linalg_LU_decomp (A->content, p, &s); 132 gsl_linalg_LU_solve (A->content, p, b->content, x->content); 133 133 gsl_permutation_free (p); 134 134 } else { // use Householder 135 // GSLMatrix *backup = new GSLMatrix(rows,columns);135 //MatrixContent *backup = new MatrixContent(rows,columns); 136 136 //*backup = *A; 137 gsl_linalg_HH_solve (A-> matrix, b->vector, x->vector);137 gsl_linalg_HH_solve (A->content, b->content, x->content); 138 138 //*A = *backup; 139 139 //delete(backup); -
src/LinearAlgebra/linearsystemofequations.hpp
r589112 r6e06bd 21 21 22 22 class Vector; 23 class GSLMatrix;24 class GSLVector;23 class MatrixContent; 24 class VectorContent; 25 25 26 26 /********************************************** declarations *******************************/ … … 44 44 bool GetSolutionAsVector(Vector &v); 45 45 46 GSLVector*b;47 GSLVector*x;48 GSLMatrix*A;46 VectorContent *b; 47 VectorContent *x; 48 MatrixContent *A; 49 49 50 50 private: -
src/LinearAlgebra/vector_ops.cpp
r589112 r6e06bd 24 24 #include "Helpers/Log.hpp" 25 25 #include "Helpers/Verbose.hpp" 26 #include "LinearAlgebra/gslmatrix.hpp"27 26 #include "leastsquaremin.hpp" 28 27 #include "Helpers/Info.hpp" -
src/Parser/PcpParser.cpp
r589112 r6e06bd 31 31 #include "Helpers/Log.hpp" 32 32 #include "Helpers/Verbose.hpp" 33 #include "LinearAlgebra/ Matrix.hpp"33 #include "LinearAlgebra/RealSpaceMatrix.hpp" 34 34 #include "molecule.hpp" 35 35 #include "PcpParser.hpp" … … 375 375 DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl); 376 376 377 const Matrix &domain = World::getInstance().getDomain().getM();377 const RealSpaceMatrix &domain = World::getInstance().getDomain().getM(); 378 378 class ThermoStatContainer *Thermostats = World::getInstance().getThermostats(); 379 379 if (!file->fail()) { -
src/Shapes/ShapeOps.cpp
r589112 r6e06bd 233 233 /************************* transform *****************/ 234 234 235 Transform_impl::Transform_impl(const Shape::impl_ptr &_arg, const Matrix &_transformation) :235 Transform_impl::Transform_impl(const Shape::impl_ptr &_arg, const RealSpaceMatrix &_transformation) : 236 236 ShapeOpsBase_impl(_arg),transformation(_transformation) 237 237 { … … 254 254 255 255 Vector Transform_impl::translateOutNormal(const Vector& point){ 256 Matrix mat = transformation.invert().transpose();256 RealSpaceMatrix mat = transformation.invert().transpose(); 257 257 return mat * point; 258 258 } … … 272 272 } 273 273 274 Shape transform(const Shape &arg, const Matrix &transformation){274 Shape transform(const Shape &arg, const RealSpaceMatrix &transformation){ 275 275 Shape::impl_ptr impl = Shape::impl_ptr(new Transform_impl(getShapeImpl(arg),transformation)); 276 276 return Shape(impl); -
src/Shapes/ShapeOps.hpp
r589112 r6e06bd 11 11 #include "Shapes/Shape.hpp" 12 12 13 class Matrix;13 class RealSpaceMatrix; 14 14 15 15 Shape resize(const Shape&,double); 16 16 Shape translate(const Shape&, const Vector&); 17 17 Shape stretch(const Shape&, const Vector&); 18 Shape transform(const Shape&,const Matrix&);18 Shape transform(const Shape&,const RealSpaceMatrix&); 19 19 20 20 #endif /* SHAPEOPS_HPP_ */ -
src/Shapes/ShapeOps_impl.hpp
r589112 r6e06bd 11 11 #include "Shapes/Shape_impl.hpp" 12 12 #include "LinearAlgebra/Vector.hpp" 13 #include "LinearAlgebra/ Matrix.hpp"13 #include "LinearAlgebra/RealSpaceMatrix.hpp" 14 14 15 15 #include <vector> … … 87 87 { 88 88 public: 89 Transform_impl(const Shape::impl_ptr&, const Matrix&);89 Transform_impl(const Shape::impl_ptr&, const RealSpaceMatrix&); 90 90 virtual ~Transform_impl(); 91 91 protected: … … 97 97 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 98 98 private: 99 Matrix transformation;100 Matrix transformationInv;99 RealSpaceMatrix transformation; 100 RealSpaceMatrix transformationInv; 101 101 }; 102 102 -
src/UIElements/CommandLineUI/CommandLineParser.cpp
r589112 r6e06bd 412 412 if ((iter->second)->Traits.hasShortForm()) { 413 413 ASSERT(result.find((iter->second)->Traits.getShortForm()) == result.end(), 414 "Short form "+ std::string((iter->second)->Traits.getShortForm())+415 " for action "+ std::string(iter->first)+" already present from "+414 "Short form "+toString((iter->second)->Traits.getShortForm())+ 415 " for action "+toString(iter->first)+" already present from "+ 416 416 std::string(result[(iter->second)->Traits.getShortForm()])+"!"); 417 417 result[(iter->second)->Traits.getShortForm()] = (iter->second)->getName(); -
src/UIElements/CommandLineUI/Query/BoxCommandLineQuery.cpp
r589112 r6e06bd 25 25 #include "Helpers/Log.hpp" 26 26 #include "Helpers/Verbose.hpp" 27 #include "LinearAlgebra/ Matrix.hpp"27 #include "LinearAlgebra/RealSpaceMatrix.hpp" 28 28 29 29 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : … … 38 38 if (CommandLineParser::getInstance().vm.count(getTitle())) { 39 39 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); 40 Matrix M;40 RealSpaceMatrix M; 41 41 M.set(0,0, temp.xx); 42 42 M.set(0,1, temp.yx); -
src/UIElements/Dialog.cpp
r589112 r6e06bd 29 29 class Box; 30 30 class element; 31 class Matrix;31 class RealSpaceMatrix; 32 32 class molecule; 33 33 class Vector; -
src/UIElements/Qt4/Pipe/BoxQtQueryPipe.cpp
r589112 r6e06bd 25 25 26 26 #include "Helpers/MemDebug.hpp" 27 #include "LinearAlgebra/ Matrix.hpp"27 #include "LinearAlgebra/RealSpaceMatrix.hpp" 28 28 #include "Box.hpp" 29 29 … … 33 33 inputTable(_inputTable) 34 34 { 35 tmpM = new Matrix();36 tmpM-> zero();35 tmpM = new RealSpaceMatrix(); 36 tmpM->setZero(); 37 37 } 38 38 -
src/UIElements/Qt4/Pipe/BoxQtQueryPipe.hpp
r589112 r6e06bd 15 15 class Box; 16 16 class QtDialog; 17 class Matrix;17 class RealSpaceMatrix; 18 18 19 19 … … 32 32 QTableWidget *inputTable; 33 33 34 Matrix *tmpM;34 RealSpaceMatrix *tmpM; 35 35 }; 36 36 -
src/UIElements/Qt4/Query/BoxQtQuery.cpp
r589112 r6e06bd 27 27 #include "UIElements/Qt4/Pipe/BoxQtQueryPipe.hpp" 28 28 29 #include "LinearAlgebra/ Matrix.hpp"29 #include "LinearAlgebra/RealSpaceMatrix.hpp" 30 30 #include "World.hpp" 31 31 … … 47 47 48 48 // fill the box with current matrix 49 const Matrix &domain = World::getInstance().getDomain().getM();49 const RealSpaceMatrix &domain = World::getInstance().getDomain().getM(); 50 50 for (int i=0;i<3;i++) 51 51 for (int j=0;j<3;j++) { -
src/UIElements/TextUI/Query/BoxTextQuery.cpp
r589112 r6e06bd 26 26 #include "Helpers/Log.hpp" 27 27 #include "Helpers/Verbose.hpp" 28 #include "LinearAlgebra/ Matrix.hpp"28 #include "LinearAlgebra/RealSpaceMatrix.hpp" 29 29 30 30 … … 46 46 std::cin >> temp[i]; 47 47 } 48 Matrix M;48 RealSpaceMatrix M; 49 49 M.set(0,0, temp[0]); 50 50 M.set(0,1, temp[1]); -
src/UIElements/TextUI/Query/VectorTextQuery.cpp
r589112 r6e06bd 27 27 #include "Helpers/Verbose.hpp" 28 28 #include "LinearAlgebra/Vector.hpp" 29 #include "LinearAlgebra/ Matrix.hpp"29 #include "LinearAlgebra/RealSpaceMatrix.hpp" 30 30 #include "World.hpp" 31 31 … … 40 40 bool TextDialog::VectorTextQuery::handle() { 41 41 std::cout << getDescription() << std::endl; 42 const Matrix &M = World::getInstance().getDomain().getM();42 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 43 43 char coords[3] = {'x', 'y', 'z'}; 44 44 for (int i=0;i<3;i++) -
src/UIElements/TextUI/Query/VectorsTextQuery.cpp
r589112 r6e06bd 27 27 #include "Helpers/Verbose.hpp" 28 28 #include "LinearAlgebra/Vector.hpp" 29 #include "LinearAlgebra/ Matrix.hpp"29 #include "LinearAlgebra/RealSpaceMatrix.hpp" 30 30 #include "World.hpp" 31 31 … … 41 41 std::cout << getDescription() << std::endl; 42 42 char coords[3] = {'x', 'y', 'z'}; 43 const Matrix &M = World::getInstance().getDomain().getM();43 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 44 44 for (int i=0;i<3;i++) 45 45 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); -
src/World.cpp
r589112 r6e06bd 38 38 #include "Helpers/Assert.hpp" 39 39 #include "Box.hpp" 40 #include "LinearAlgebra/ Matrix.hpp"40 #include "LinearAlgebra/RealSpaceMatrix.hpp" 41 41 #include "defs.hpp" 42 42 … … 100 100 } 101 101 102 void World::setDomain(const Matrix &mat){102 void World::setDomain(const RealSpaceMatrix &mat){ 103 103 OBSERVE; 104 104 *cell_size = mat; … … 108 108 { 109 109 OBSERVE; 110 Matrix M = ReturnFullMatrixforSymmetric(matrix);110 RealSpaceMatrix M = ReturnFullMatrixforSymmetric(matrix); 111 111 cell_size->setM(M); 112 112 } … … 747 747 { 748 748 cell_size = new Box; 749 Matrix domain;749 RealSpaceMatrix domain; 750 750 domain.at(0,0) = 20; 751 751 domain.at(1,1) = 20; -
src/World.hpp
r589112 r6e06bd 41 41 class config; 42 42 class ManipulateAtomsProcess; 43 class Matrix;43 class RealSpaceMatrix; 44 44 class molecule; 45 45 class MoleculeDescriptor; … … 147 147 * Matrix needs to be symmetric 148 148 */ 149 void setDomain(const Matrix &mat);149 void setDomain(const RealSpaceMatrix &mat); 150 150 151 151 /** -
src/analysis_correlation.cpp
r589112 r6e06bd 33 33 #include "triangleintersectionlist.hpp" 34 34 #include "LinearAlgebra/Vector.hpp" 35 #include "LinearAlgebra/ Matrix.hpp"35 #include "LinearAlgebra/RealSpaceMatrix.hpp" 36 36 #include "Helpers/Verbose.hpp" 37 37 #include "World.hpp" … … 145 145 outmap = new PairCorrelationMap; 146 146 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ 147 Matrix FullMatrix = World::getInstance().getDomain().getM();148 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();147 RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); 148 RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 149 149 DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 150 150 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 244 244 outmap = new CorrelationToPointMap; 245 245 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 246 Matrix FullMatrix = World::getInstance().getDomain().getM();247 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();246 RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); 247 RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 248 248 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 249 249 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { … … 342 342 BoundaryTriangleSet *ShortestTriangle = NULL; 343 343 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 344 Matrix FullMatrix = World::getInstance().getDomain().getM();345 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv();344 RealSpaceMatrix FullMatrix = World::getInstance().getDomain().getM(); 345 RealSpaceMatrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 346 346 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 347 347 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { -
src/atom_atominfo.hpp
r589112 r6e06bd 26 26 class AtomInfo; 27 27 class element; 28 class Matrix;28 class RealSpaceMatrix; 29 29 30 30 /********************************************** declarations *******************************/ -
src/boundary.cpp
r589112 r6e06bd 40 40 #include "World.hpp" 41 41 #include "LinearAlgebra/Plane.hpp" 42 #include "LinearAlgebra/ Matrix.hpp"42 #include "LinearAlgebra/RealSpaceMatrix.hpp" 43 43 #include "Box.hpp" 44 44 … … 792 792 int N[NDIM]; 793 793 int n[NDIM]; 794 const Matrix &M = World::getInstance().getDomain().getM();795 Matrix Rotations;796 const Matrix &MInverse = World::getInstance().getDomain().getMinv();794 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 795 RealSpaceMatrix Rotations; 796 const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv(); 797 797 Vector AtomTranslations; 798 798 Vector FillerTranslations; … … 944 944 int N[NDIM]; 945 945 int n[NDIM]; 946 const Matrix &M = World::getInstance().getDomain().getM();947 Matrix Rotations;948 const Matrix &MInverse = World::getInstance().getDomain().getMinv();946 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 947 RealSpaceMatrix Rotations; 948 const RealSpaceMatrix &MInverse = World::getInstance().getDomain().getMinv(); 949 949 Vector AtomTranslations; 950 950 Vector FillerTranslations; -
src/config.cpp
r589112 r6e06bd 39 39 #include "ThermoStatContainer.hpp" 40 40 #include "World.hpp" 41 #include "LinearAlgebra/ Matrix.hpp"41 #include "LinearAlgebra/RealSpaceMatrix.hpp" 42 42 #include "Box.hpp" 43 43 … … 637 637 { 638 638 bool result = true; 639 const Matrix &domain = World::getInstance().getDomain().getM();639 const RealSpaceMatrix &domain = World::getInstance().getDomain().getM(); 640 640 ofstream * const output = new ofstream(filename, ios::out); 641 641 if (output != NULL) { -
src/ellipsoid.cpp
r589112 r6e06bd 34 34 #include "tesselation.hpp" 35 35 #include "LinearAlgebra/Vector.hpp" 36 #include "LinearAlgebra/ Matrix.hpp"36 #include "LinearAlgebra/RealSpaceMatrix.hpp" 37 37 #include "Helpers/Verbose.hpp" 38 38 … … 48 48 Vector helper, RefPoint; 49 49 double distance = -1.; 50 Matrix Matrix;50 RealSpaceMatrix Matrix; 51 51 double InverseLength[3]; 52 52 double psi,theta,phi; // euler angles in ZX'Z'' convention -
src/molecule.cpp
r589112 r6e06bd 43 43 #include "tesselation.hpp" 44 44 #include "LinearAlgebra/Vector.hpp" 45 #include "LinearAlgebra/ Matrix.hpp"45 #include "LinearAlgebra/RealSpaceMatrix.hpp" 46 46 #include "World.hpp" 47 47 #include "Box.hpp" … … 316 316 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 317 317 Vector InBondvector; // vector in direction of *Bond 318 const Matrix &matrix = World::getInstance().getDomain().getM();318 const RealSpaceMatrix &matrix = World::getInstance().getDomain().getM(); 319 319 bond *Binder = NULL; 320 320 … … 778 778 void molecule::SetBoxDimension(Vector *dim) 779 779 { 780 Matrix domain;780 RealSpaceMatrix domain; 781 781 for(int i =0; i<NDIM;++i) 782 782 domain.at(i,i) = dim->at(i); … … 862 862 bool molecule::CheckBounds(const Vector *x) const 863 863 { 864 const Matrix &domain = World::getInstance().getDomain().getM();864 const RealSpaceMatrix &domain = World::getInstance().getDomain().getM(); 865 865 bool result = true; 866 866 for (int i=0;i<NDIM;i++) { -
src/molecule_fragmentation.cpp
r589112 r6e06bd 34 34 #include "periodentafel.hpp" 35 35 #include "World.hpp" 36 #include "LinearAlgebra/ Matrix.hpp"36 #include "LinearAlgebra/RealSpaceMatrix.hpp" 37 37 #include "Box.hpp" 38 38 #include "stackclass.hpp" … … 1739 1739 atom *Walker = NULL; 1740 1740 atom *OtherWalker = NULL; 1741 Matrix matrix = World::getInstance().getDomain().getM();1741 RealSpaceMatrix matrix = World::getInstance().getDomain().getM(); 1742 1742 enum Shading *ColorList = NULL; 1743 1743 double tmp; -
src/molecule_geometry.cpp
r589112 r6e06bd 24 24 #include "Helpers/Verbose.hpp" 25 25 #include "LinearAlgebra/Line.hpp" 26 #include "LinearAlgebra/ Matrix.hpp"26 #include "LinearAlgebra/RealSpaceMatrix.hpp" 27 27 #include "LinearAlgebra/Plane.hpp" 28 28 … … 166 166 { 167 167 Vector *a = new Vector(0.5,0.5,0.5); 168 const Matrix &M = World::getInstance().getDomain().getM();168 const RealSpaceMatrix &M = World::getInstance().getDomain().getM(); 169 169 (*a) *= M; 170 170 return a; … … 287 287 void molecule::DeterminePeriodicCenter(Vector ¢er) 288 288 { 289 const Matrix &matrix = World::getInstance().getDomain().getM();290 const Matrix &inversematrix = World::getInstance().getDomain().getM();289 const RealSpaceMatrix &matrix = World::getInstance().getDomain().getM(); 290 const RealSpaceMatrix &inversematrix = World::getInstance().getDomain().getM(); 291 291 double tmp; 292 292 bool flag; -
src/molecule_graph.cpp
r589112 r6e06bd 36 36 #include "Helpers/fast_functions.hpp" 37 37 #include "Helpers/Assert.hpp" 38 #include "LinearAlgebra/ Matrix.hpp"38 #include "LinearAlgebra/RealSpaceMatrix.hpp" 39 39 #include "Box.hpp" 40 40 #include "stackclass.hpp" -
src/moleculelist.cpp
r589112 r6e06bd 40 40 #include "tesselation.hpp" 41 41 #include "Helpers/Assert.hpp" 42 #include "LinearAlgebra/ Matrix.hpp"42 #include "LinearAlgebra/RealSpaceMatrix.hpp" 43 43 #include "Box.hpp" 44 44 #include "stackclass.hpp" … … 487 487 int FragmentCounter = 0; 488 488 ofstream output; 489 Matrix cell_size = World::getInstance().getDomain().getM();490 Matrix cell_size_backup = cell_size;489 RealSpaceMatrix cell_size = World::getInstance().getDomain().getM(); 490 RealSpaceMatrix cell_size_backup = cell_size; 491 491 492 492 // store the fragments as config and as xyz … … 629 629 // center at set box dimensions 630 630 mol->CenterEdge(¢er); 631 Matrix domain;631 RealSpaceMatrix domain; 632 632 for(int i =0;i<NDIM;++i) 633 633 domain.at(i,i) = center[i]; -
src/tesselationhelpers.cpp
r589112 r6e06bd 38 38 #include "Helpers/Verbose.hpp" 39 39 #include "LinearAlgebra/Plane.hpp" 40 #include "LinearAlgebra/ Matrix.hpp"40 #include "LinearAlgebra/RealSpaceMatrix.hpp" 41 41 42 42 void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS) 43 43 { 44 44 Info FunctionInfo(__func__); 45 Matrix mat;45 RealSpaceMatrix mat; 46 46 double m11, m12, m13, m14; 47 47 -
src/unittests/BoxUnittest.cpp
r589112 r6e06bd 29 29 30 30 #include "LinearAlgebra/Vector.hpp" 31 #include "LinearAlgebra/ Matrix.hpp"31 #include "LinearAlgebra/RealSpaceMatrix.hpp" 32 32 #include "Box.hpp" 33 33 #include "Helpers/Assert.hpp" … … 40 40 void BoxUnittest::setUp(){ 41 41 ASSERT_DO(Assert::Throw); 42 unit = new Matrix;43 unit-> one();44 zero = new Matrix;45 invertible = new Matrix;42 unit = new RealSpaceMatrix; 43 unit->setIdentity(); 44 zero = new RealSpaceMatrix; 45 invertible = new RealSpaceMatrix; 46 46 invertible->diagonal() = Vector(1,2,3); 47 uninvertible = new Matrix;47 uninvertible = new RealSpaceMatrix; 48 48 uninvertible->column(0) = Vector(1,0,1); 49 49 uninvertible->column(2) = Vector(1,0,1); 50 50 51 Matrix boxMat;51 RealSpaceMatrix boxMat; 52 52 unitBox = new Box; 53 53 stretchedBox1 = new Box; 54 boxMat. one();54 boxMat.setIdentity(); 55 55 boxMat.diagonal() = Vector(1,2,3); 56 56 stretchedBox1->setM(boxMat); 57 57 58 58 stretchedBox2 = new Box; 59 boxMat. one();59 boxMat.setIdentity(); 60 60 boxMat.diagonal() = Vector(2,3,1); 61 61 stretchedBox2->setM(boxMat); 62 62 63 63 stretchedBox3 = new Box; 64 boxMat. one();64 boxMat.setIdentity(); 65 65 boxMat.diagonal() = Vector(3,1,2); 66 66 stretchedBox3->setM(boxMat); 67 67 68 68 stretchedBox4 = new Box; 69 boxMat. one();69 boxMat.setIdentity(); 70 70 boxMat.diagonal() = Vector(2,2,2); 71 71 stretchedBox4->setM(boxMat); 72 72 73 73 tiltedBox1 = new Box; 74 boxMat. one();74 boxMat.setIdentity(); 75 75 boxMat.column(0) = Vector(1,0,1); 76 76 tiltedBox1->setM(boxMat); 77 77 78 78 tiltedBox2 = new Box; 79 boxMat. one();79 boxMat.setIdentity(); 80 80 boxMat.column(0) = Vector(1,1,1); 81 81 tiltedBox2->setM(boxMat); 82 82 83 83 tiltedBox3 = new Box; 84 boxMat. one();84 boxMat.setIdentity(); 85 85 boxMat.column(1) = Vector(0,1,1); 86 86 tiltedBox3->setM(boxMat); 87 87 88 88 tiltedBox4 = new Box; 89 boxMat. one();89 boxMat.setIdentity(); 90 90 boxMat.column(0) = Vector(1,1,1); 91 91 boxMat.column(1) = Vector(0,1,1); -
src/unittests/BoxUnittest.hpp
r589112 r6e06bd 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 class Matrix;13 class RealSpaceMatrix; 14 14 class Box; 15 15 … … 38 38 void BoundaryMixedTest(); 39 39 40 Matrix *unit;41 Matrix *zero;42 Matrix *invertible;43 Matrix *uninvertible;40 RealSpaceMatrix *unit; 41 RealSpaceMatrix *zero; 42 RealSpaceMatrix *invertible; 43 RealSpaceMatrix *uninvertible; 44 44 45 45 Box *unitBox; -
src/unittests/Makefile.am
r589112 r6e06bd 22 22 CountBondsUnitTest \ 23 23 FormulaUnittest \ 24 GSLMatrixSymmetricUnitTest \25 GSLMatrixUnitTest \26 GSLVectorUnitTest \27 24 InfoUnitTest \ 28 25 LinearSystemOfEquationsUnitTest \ … … 32 29 LogUnitTest \ 33 30 manipulateAtomsTest \ 31 MatrixContentSymmetricUnitTest \ 32 MatrixContentUnitTest \ 34 33 MatrixUnittest \ 35 34 MenuDescriptionUnitTest \ … … 46 45 Tesselation_BoundaryTriangleUnitTest \ 47 46 Tesselation_InOutsideUnitTest \ 47 VectorContentUnitTest \ 48 48 VectorUnitTest 49 49 … … 82 82 CountBondsUnitTest.cpp \ 83 83 FormulaUnittest.cpp \ 84 gslmatrixsymmetricunittest.cpp \85 gslmatrixunittest.cpp \86 gslvectorunittest.cpp \87 84 infounittest.cpp \ 88 85 linearsystemofequationsunittest.cpp \ … … 91 88 listofbondsunittest.cpp \ 92 89 logunittest.cpp \ 90 MatrixContentSymmetricUnittest.cpp \ 91 MatrixContentUnittest.cpp \ 93 92 MatrixUnittest.cpp \ 94 93 manipulateAtomsTest.cpp \ … … 106 105 tesselation_boundarytriangleunittest.cpp \ 107 106 tesselation_insideoutsideunittest.cpp \ 107 VectorContentUnittest.cpp \ 108 108 vectorunittest.cpp 109 109 … … 122 122 CountBondsUnitTest.hpp \ 123 123 FormulaUnittest.hpp \ 124 gslmatrixsymmetricunittest.hpp \125 gslmatrixunittest.hpp \126 gslvectorunittest.hpp \127 124 infounittest.hpp \ 128 125 linearsystemofequationsunittest.hpp \ … … 132 129 logunittest.hpp \ 133 130 manipulateAtomsTest.hpp \ 131 MatrixContentSymmetricUnittest.hpp \ 132 MatrixContentUnittest.hpp \ 134 133 MatrixUnittest.hpp \ 135 134 MenuDescriptionUnitTest.hpp \ … … 145 144 tesselation_boundarytriangleunittest.hpp \ 146 145 tesselation_insideoutsideunittest.hpp \ 146 VectorContentUnittest.hpp \ 147 147 vectorunittest.hpp 148 148 … … 187 187 FormulaUnittest_LDADD = ${ALLLIBS} 188 188 189 GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp 190 GSLMatrixSymmetricUnitTest_LDADD = ${ALLLIBS} 191 192 GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp 193 GSLMatrixUnitTest_LDADD = ${ALLLIBS} 194 195 GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp 196 GSLVectorUnitTest_LDADD = ${ALLLIBS} 189 MatrixContentSymmetricUnitTest_SOURCES = UnitTestMain.cpp MatrixContentSymmetricUnittest.cpp MatrixContentSymmetricUnittest 190 MatrixContentSymmetricUnitTest_LDADD = ${ALLLIBS} 191 192 MatrixContentUnitTest_SOURCES = UnitTestMain.cpp MatrixContentUnittest.cpp MatrixContentUnittest.hpp 193 MatrixContentUnitTest_LDADD = ${ALLLIBS} 197 194 198 195 InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp … … 262 259 TestRunner_LDADD = ${UILIBS} ${ALLLIBS} 263 260 261 VectorContentUnitTest_SOURCES = UnitTestMain.cpp VectorContentUnittest.cpp VectorContentUnittest.hpp 262 VectorContentUnitTest_LDADD = ${ALLLIBS} 263 264 264 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 265 265 VectorUnitTest_LDADD = ${ALLLIBS} -
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); -
src/unittests/MatrixUnittest.hpp
r589112 r6e06bd 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 class Matrix;13 class RealSpaceMatrix; 14 14 15 15 class MatrixUnittest : public CppUnit::TestFixture … … 39 39 void VecMultTest(); 40 40 41 Matrix *zero;42 Matrix *one;43 Matrix *full;44 Matrix *diagonal;45 Matrix *perm1;46 Matrix *perm2;47 Matrix *perm3;48 Matrix *perm4;49 Matrix *perm5;41 RealSpaceMatrix *zero; 42 RealSpaceMatrix *one; 43 RealSpaceMatrix *full; 44 RealSpaceMatrix *diagonal; 45 RealSpaceMatrix *perm1; 46 RealSpaceMatrix *perm2; 47 RealSpaceMatrix *perm3; 48 RealSpaceMatrix *perm4; 49 RealSpaceMatrix *perm5; 50 50 }; 51 51 -
src/unittests/vectorunittest.cpp
r589112 r6e06bd 31 31 #include "LinearAlgebra/Plane.hpp" 32 32 #include "Exceptions/LinearDependenceException.hpp" 33 #include "LinearAlgebra/ Matrix.hpp"33 #include "LinearAlgebra/RealSpaceMatrix.hpp" 34 34 35 35 #ifdef HAVE_TESTRUNNER
Note:
See TracChangeset
for help on using the changeset viewer.