Changes in / [589112:6e06bd]


Ignore:
Location:
src
Files:
11 added
10 deleted
53 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp

    r589112 r6e06bd  
    2222#include "Helpers/Log.hpp"
    2323#include "Helpers/Verbose.hpp"
    24 #include "LinearAlgebra/Matrix.hpp"
     24#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2525#include "LinearAlgebra/Vector.hpp"
    2626#include "element.hpp"
     
    4040/** =========== define the function ====================== */
    4141Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
    42   Matrix InertiaTensor;
     42  RealSpaceMatrix InertiaTensor;
    4343
    4444  DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     
    4848
    4949    // reset inertia tensor
    50     InertiaTensor.zero();
     50    InertiaTensor.setZero();
    5151
    5252    // sum up inertia tensor
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    r589112 r6e06bd  
    2323#include "Helpers/Verbose.hpp"
    2424#include "LinearAlgebra/Line.hpp"
    25 #include "LinearAlgebra/Matrix.hpp"
     25#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2626#include "LinearAlgebra/Vector.hpp"
    2727#include "element.hpp"
     
    5050    mol = iter->second;
    5151    DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    52     Matrix InertiaTensor;
     52    RealSpaceMatrix InertiaTensor;
    5353    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    5454
    5555    // reset inertia tensor
    56     InertiaTensor.zero();
     56    InertiaTensor.setZero();
    5757
    5858    // sum up inertia tensor
     
    105105    // summing anew for debugging (resulting matrix has to be diagonal!)
    106106    // reset inertia tensor
    107     InertiaTensor.zero();
     107    InertiaTensor.setZero();
    108108
    109109    // sum up inertia tensor
  • src/Actions/SelectionAction/AllAtomsInsideCuboidAction.cpp

    r589112 r6e06bd  
    2525#include "Helpers/Log.hpp"
    2626#include "Helpers/Verbose.hpp"
    27 #include "LinearAlgebra/Matrix.hpp"
     27#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2828#include "LinearAlgebra/Vector.hpp"
    2929#include "Shapes/BaseShapes.hpp"
     
    4545Action::state_ptr SelectionAllAtomsInsideCuboidAction::performCall() {
    4646  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
    47   Matrix RotationMatrix;
     47  RealSpaceMatrix RotationMatrix;
    4848
    4949  // obtain information
    5050  getParametersfromValueStorage();
    5151
    52   RotationMatrix.rotation(params.Xangle, params.Yangle, params.Zangle);
     52  RotationMatrix.setRotation(params.Xangle, params.Yangle, params.Zangle);
    5353
    5454  DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "." << endl);
     
    7070Action::state_ptr SelectionAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){
    7171  SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get());
    72   Matrix RotationMatrix;
     72  RealSpaceMatrix RotationMatrix;
    7373
    74   RotationMatrix.rotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);
     74  RotationMatrix.setRotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);
    7575  Shape s = translate(transform(stretch(Cuboid(),state->params.extension),RotationMatrix),state->params.position);
    7676  World::getInstance().selectAllAtoms(AtomByShape(s));
  • src/Actions/SelectionAction/NotAllAtomsInsideCuboidAction.cpp

    r589112 r6e06bd  
    2525#include "Helpers/Log.hpp"
    2626#include "Helpers/Verbose.hpp"
    27 #include "LinearAlgebra/Matrix.hpp"
     27#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2828#include "LinearAlgebra/Vector.hpp"
    2929#include "Shapes/BaseShapes.hpp"
     
    4545Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performCall() {
    4646  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
    47   Matrix RotationMatrix;
     47  RealSpaceMatrix RotationMatrix;
    4848
    4949  // obtain information
    5050  getParametersfromValueStorage();
    51   RotationMatrix.rotation(params.Xangle, params.Yangle, params.Zangle);
     51  RotationMatrix.setRotation(params.Xangle, params.Yangle, params.Zangle);
    5252
    5353  DoLog(1) && (Log() << Verbose(1) << "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "." << endl);
     
    7070Action::state_ptr SelectionNotAllAtomsInsideCuboidAction::performRedo(Action::state_ptr _state){
    7171  SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get());
    72   Matrix RotationMatrix;
     72  RealSpaceMatrix RotationMatrix;
    7373
    74   RotationMatrix.rotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);
     74  RotationMatrix.setRotation(state->params.Xangle, state->params.Yangle, state->params.Zangle);
    7575  Shape s = translate(transform(stretch(Cuboid(),state->params.extension),RotationMatrix),state->params.position);
    7676  World::getInstance().unselectAllAtoms(AtomByShape(s));
  • src/Actions/ValueStorage.cpp

    r589112 r6e06bd  
    3131#include "Helpers/Verbose.hpp"
    3232#include "LinearAlgebra/BoxVector.hpp"
    33 #include "LinearAlgebra/Matrix.hpp"
     33#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3434#include "LinearAlgebra/Vector.hpp"
    3535#include "atom.hpp"
     
    9595
    9696void ValueStorage::queryCurrentValue(const char * name, class Box &_T) {
    97   Matrix M;
     97  RealSpaceMatrix M;
    9898  double tmp;
    9999  if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
     
    254254void ValueStorage::setCurrentValue(const char * name, class Box &_T)
    255255{
    256   const Matrix &M = _T.getM();
     256  const RealSpaceMatrix &M = _T.getM();
    257257  if (typeid( Box ) == *(OptionRegistry_instance.getOptionByName(name)->getType())) {
    258258    std::ostringstream stream;
  • src/Actions/WorldAction/CenterOnEdgeAction.cpp

    r589112 r6e06bd  
    2424#include "LinearAlgebra/Vector.hpp"
    2525#include "World.hpp"
    26 #include "LinearAlgebra/Matrix.hpp"
     26#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2727
    2828#include <iostream>
     
    5959  }
    6060  // set new box size
    61   Matrix domain;
     61  RealSpaceMatrix domain;
    6262  for (int i=0;i<NDIM;i++) {
    6363    double tmp = Max[i]-Min[i];
  • src/Actions/WorldAction/ChangeBoxAction.cpp

    r589112 r6e06bd  
    2424#include "World.hpp"
    2525#include "Box.hpp"
    26 #include "LinearAlgebra/Matrix.hpp"
     26#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2727
    2828#include <iostream>
  • src/Actions/WorldAction/RepeatBoxAction.cpp

    r589112 r6e06bd  
    2525#include "molecule.hpp"
    2626#include "LinearAlgebra/Vector.hpp"
    27 #include "LinearAlgebra/Matrix.hpp"
     27#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2828#include "Helpers/Verbose.hpp"
    2929#include "World.hpp"
     
    6363
    6464  (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;
    6767  Vector x,y;
    6868  int n[NDIM];
    69   Matrix repMat;
     69  RealSpaceMatrix repMat;
    7070  for (int axis = 0; axis < NDIM; axis++) {
    7171    params.Repeater[axis] = floor(params.Repeater[axis]);
  • src/Actions/WorldAction/ScaleBoxAction.cpp

    r589112 r6e06bd  
    2626#include "World.hpp"
    2727#include "Box.hpp"
    28 #include "LinearAlgebra/Matrix.hpp"
     28#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2929
    3030#include <iostream>
     
    5353  }
    5454
    55   Matrix M = World::getInstance().getDomain().getM();
    56   Matrix scale;
     55  RealSpaceMatrix M = World::getInstance().getDomain().getM();
     56  RealSpaceMatrix scale;
    5757
    5858  for (int i=0;i<NDIM;i++) {
  • src/Box.cpp

    r589112 r6e06bd  
    2626#include <cstdlib>
    2727
    28 #include "LinearAlgebra/Matrix.hpp"
     28#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2929#include "LinearAlgebra/Vector.hpp"
    3030#include "LinearAlgebra/Plane.hpp"
     
    3838Box::Box()
    3939{
    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();
    4444  conditions.resize(3);
    4545  conditions[0] = conditions[1] = conditions[2] = Wrap;
     
    4747
    4848Box::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);
    5151  conditions = src.conditions;
    5252}
     
    5858}
    5959
    60 const Matrix &Box::getM() const{
     60const RealSpaceMatrix &Box::getM() const{
    6161  return *M;
    6262}
    63 const Matrix &Box::getMinv() const{
     63const RealSpaceMatrix &Box::getMinv() const{
    6464  return *Minv;
    6565}
    6666
    67 void Box::setM(Matrix _M){
     67void Box::setM(RealSpaceMatrix _M){
    6868  ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible");
    6969  *M    =_M;
     
    253253void Box::setCuboid(const Vector &endpoint){
    254254  ASSERT(endpoint[0]>0 && endpoint[1]>0 && endpoint[2]>0,"Vector does not define a full cuboid");
    255   M->one();
     255  M->setIdentity();
    256256  M->diagonal()=endpoint;
    257257  Vector &dinv = Minv->diagonal();
     
    264264    delete M;
    265265    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);
    268268    conditions = src.conditions;
    269269  }
     
    271271}
    272272
    273 Box &Box::operator=(const Matrix &mat){
     273Box &Box::operator=(const RealSpaceMatrix &mat){
    274274  setM(mat);
    275275  return *this;
  • src/Box.hpp

    r589112 r6e06bd  
    99#define BOX_HPP_
    1010
    11 class Matrix;
     11class RealSpaceMatrix;
    1212class Vector;
    1313class Shape;
     
    4444   * Get the matrix describing the form of the parallelepiped
    4545   */
    46   const Matrix &getM() const;
     46  const RealSpaceMatrix &getM() const;
    4747
    4848  /**
    4949   * Get the inverse of the matrix M (see above).
    5050   */
    51   const Matrix &getMinv() const;
     51  const RealSpaceMatrix &getMinv() const;
    5252
    5353  /**
    5454   * Set the form of the parallelepiped.
    5555   */
    56   void setM(Matrix);
     56  void setM(RealSpaceMatrix);
    5757
    5858  Box &operator=(const Box&);
    59   Box &operator=(const Matrix&);
     59  Box &operator=(const RealSpaceMatrix&);
    6060
    6161  /**
     
    110110private:
    111111  Conditions_t conditions;
    112   Matrix *M;    //!< Defines the layout of the box
    113   Matrix *Minv; //!< Inverse of M to avoid recomputation
     112  RealSpaceMatrix *M;    //!< Defines the layout of the box
     113  RealSpaceMatrix *Minv; //!< Inverse of M to avoid recomputation
    114114};
    115115
  • src/Helpers/Assert.hpp

    r589112 r6e06bd  
    1414#include<vector>
    1515#include<map>
     16
     17#include "Helpers/toString.hpp"
    1618
    1719/**
     
    184186 * This can be done in the following way:
    185187 * @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 ends
    189  * 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.
    190192 * <li> <H4> ASSERT() is broken. When I abort the program it says something about an
    191193 * "Illegal instruction"</H4>
  • src/LinearAlgebra/Line.cpp

    r589112 r6e06bd  
    2828#include "Helpers/Log.hpp"
    2929#include "Helpers/Verbose.hpp"
    30 #include "LinearAlgebra/gslmatrix.hpp"
     30#include "LinearAlgebra/MatrixContent.hpp"
    3131#include "Helpers/Info.hpp"
    3232#include "Exceptions/LinearDependenceException.hpp"
     
    116116  Vector res;
    117117
    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.);
    121121  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]);
    126126  }
    127127
  • src/LinearAlgebra/Makefile.am

    r589112 r6e06bd  
    1212  ${HELPERSOURCE} \
    1313  BoxVector.cpp \
    14   gslmatrix.cpp \
    1514  gslvector.cpp \
    1615  Line.cpp \
     
    1817  LineSegmentSet.cpp \
    1918  linearsystemofequations.cpp \
    20   Matrix.cpp \
     19  MatrixContent.cpp \
    2120  Plane.cpp \
     21  RealSpaceMatrix.cpp \
    2222  Space.cpp \
    2323  vector_ops.cpp \
    2424  Vector.cpp \
     25  VectorContent.cpp \
    2526  VectorInterface.cpp
    2627                           
    2728LINALGHEADER = \
    2829  BoxVector.hpp \
    29   gslmatrix.hpp \
    3030  gslvector.hpp \
    3131  Line.hpp \
     
    3333  LineSegmentSet.hpp \
    3434  linearsystemofequations.hpp \
    35   Matrix.hpp \
     35  MatrixContent.hpp \
     36  RealSpaceMatrix.hpp \
    3637  Plane.hpp \
    3738  Space.hpp \
    3839  vector_ops.hpp \
    3940  Vector.hpp \
     41  VectorContent.hpp \
    4042  VectorInterface.hpp
    4143
  • src/LinearAlgebra/MatrixContent.hpp

    r589112 r6e06bd  
    99#define MATRIXCONTENT_HPP_
    1010
    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 *
    1733 */
    1834
    1935#include <gsl/gsl_matrix.h>
    2036
    21 struct MatrixContent{
     37class Vector;
     38
     39class 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;
     47public:
     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
     93protected:
     94  double *Pointer(size_t m, size_t n);
     95  const double *const_Pointer(size_t m, size_t n) const;
     96
     97private:
    2298  gsl_matrix * content;
     99  const size_t rows;      // store for internal purposes
     100  const size_t columns;  // store for internal purposes
    23101};
    24102
     103const MatrixContent operator*(const double factor,const MatrixContent& mat);
     104const MatrixContent operator*(const MatrixContent &mat,const double factor);
     105Vector operator*(const MatrixContent &mat,const Vector &vec);
     106
    25107#endif /* MATRIXCONTENT_HPP_ */
  • src/LinearAlgebra/Vector.cpp

    r589112 r6e06bd  
    4141Vector::Vector()
    4242{
    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 */
    5049Vector::Vector(const Vector& src)
    5150{
    52   content = new VectorContent();
    53   gsl_vector_memcpy(content->content, src.content->content);
     51  content = new VectorContent(*(src.content));
    5452}
    5553
    5654/** Constructor of class vector.
     55 * \param x1 first component
     56 * \param x2 second component
     57 * \param x3 third component
    5758 */
    5859Vector::Vector(const double x1, const double x2, const double x3)
    5960{
    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;
    6465};
    6566
    6667/** Constructor of class vector.
     68 * \param x[3] three values to initialize Vector with
    6769 */
    6870Vector::Vector(const double x[3])
    6971{
    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 */
     80Vector::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 */
     89Vector::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
    8297 */
    8398Vector& Vector::operator=(const Vector& src){
    8499  // check for self assignment
    85100  if(&src!=this){
    86     gsl_vector_memcpy(content->content, src.content->content);
     101    *content = *(src.content);
    87102  }
    88103  return *this;
     
    90105
    91106/** Desctructor of class vector.
     107 * Vector::content is deleted.
    92108 */
    93109Vector::~Vector() {
  • src/LinearAlgebra/Vector.hpp

    r589112 r6e06bd  
    2222
    2323class Vector;
    24 class Matrix;
     24class RealSpaceMatrix;
     25class MatrixContent;
    2526struct VectorContent;
    2627
     
    3132 */
    3233class 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
    3536public:
    3637  Vector();
     
    103104
    104105private:
    105   Vector(VectorContent *);
     106  explicit Vector(VectorContent *&);
     107  explicit Vector(VectorContent &_content);
    106108  VectorContent *content;
    107109
  • src/LinearAlgebra/VectorContent.hpp

    r589112 r6e06bd  
    1818 */
    1919
     20#include <iosfwd>
     21
    2022#include <gsl/gsl_vector.h>
    2123
     24class Vector;
     25
     26/** Dummy structure to create a unique signature.
     27 *
     28 */
    2229struct BaseCase{};
    2330
    24 struct VectorContent{
    25   VectorContent(){
    26     content =  gsl_vector_calloc (NDIM);
    27   }
    28   VectorContent(BaseCase){
     31class 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);
    2937
    30   }
    31   virtual ~VectorContent(){
    32     if(content){
    33       gsl_vector_free(content);
    34       content = 0;
    35     }
    36   }
     38public:
     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;
    3787  gsl_vector *content;
     88private:
    3889};
    3990
    40 struct VectorViewContent : public VectorContent{
     91std::ostream & operator << (std::ostream& ost, const VectorContent &m);
     92VectorContent const operator*(const VectorContent& a, const double m);
     93VectorContent const operator*(const double m, const VectorContent& a);
     94VectorContent const operator+(const VectorContent& a, const VectorContent& b);
     95VectorContent 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 */
     106struct VectorViewContent : public VectorContent
     107{
    41108  VectorViewContent(gsl_vector_view _view) :
    42109    VectorContent(BaseCase()),
    43110    view(_view)
    44111  {
     112    dimension = _view.vector.size;
    45113    content=&view.vector;
    46114  }
    47   virtual ~VectorViewContent(){
     115  ~VectorViewContent(){
    48116    content=0;
    49117  }
  • src/LinearAlgebra/linearsystemofequations.cpp

    r589112 r6e06bd  
    2121
    2222#include "defs.hpp"
    23 #include "LinearAlgebra/gslmatrix.hpp"
    24 #include "LinearAlgebra/gslvector.hpp"
     23#include "LinearAlgebra/MatrixContent.hpp"
     24#include "LinearAlgebra/VectorContent.hpp"
    2525#include "LinearAlgebra/linearsystemofequations.hpp"
     26#include "Helpers/Assert.hpp"
    2627#include "Helpers/logger.hpp"
    2728#include "LinearAlgebra/Vector.hpp"
    2829
    29 #include <cassert>
    3030#include <gsl/gsl_permutation.h>
    3131
     
    3737LinearSystemOfEquations::LinearSystemOfEquations(int m, int n) : rows(m), columns(n), IsSymmetric(false)
    3838{
    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);
    4242};
    4343
     
    5858bool LinearSystemOfEquations::SetSymmetric(bool symmetric)
    5959{
    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.");
    6161  return (IsSymmetric = symmetric);
    6262};
     
    6767void LinearSystemOfEquations::Setb(Vector *x)
    6868{
    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);
    7171};
    7272
     
    7676void LinearSystemOfEquations::Setb(double *x)
    7777{
    78   b->SetFromDoubleArray(x);
     78  b->setFromDoubleArray(x);
    7979};
    8080
     
    8585void LinearSystemOfEquations::SetA(double *x)
    8686{
    87   A->SetFromDoubleArray(x);
     87  A->setFromDoubleArray(x);
    8888};
    8989
     
    9898  // copy solution
    9999  for (size_t i=0;i<x->dimension;i++) {
    100     array[i] = x->Get(i);
     100    array[i] = x->at(i);
    101101  }
    102102  return status;
     
    109109bool LinearSystemOfEquations::GetSolutionAsVector(Vector &v)
    110110{
    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.");
    112112  bool status = Solve();
    113113
    114114  // copy solution
    115115  for (size_t i=0;i<x->dimension;i++)
    116     v[i] = x->Get(i);
     116    v[i] = x->at(i);
    117117  return status;
    118118};
     
    129129  if (IsSymmetric) { // use LU
    130130    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);
    133133    gsl_permutation_free (p);
    134134  } else {  // use Householder
    135     //GSLMatrix *backup = new GSLMatrix(rows,columns);
     135    //MatrixContent *backup = new MatrixContent(rows,columns);
    136136    //*backup = *A;
    137     gsl_linalg_HH_solve (A->matrix, b->vector, x->vector);
     137    gsl_linalg_HH_solve (A->content, b->content, x->content);
    138138    //*A = *backup;
    139139    //delete(backup);
  • src/LinearAlgebra/linearsystemofequations.hpp

    r589112 r6e06bd  
    2121
    2222class Vector;
    23 class GSLMatrix;
    24 class GSLVector;
     23class MatrixContent;
     24class VectorContent;
    2525
    2626/********************************************** declarations *******************************/
     
    4444  bool GetSolutionAsVector(Vector &v);
    4545
    46   GSLVector *b;
    47   GSLVector *x;
    48   GSLMatrix *A;
     46  VectorContent *b;
     47  VectorContent *x;
     48  MatrixContent *A;
    4949
    5050private:
  • src/LinearAlgebra/vector_ops.cpp

    r589112 r6e06bd  
    2424#include "Helpers/Log.hpp"
    2525#include "Helpers/Verbose.hpp"
    26 #include "LinearAlgebra/gslmatrix.hpp"
    2726#include "leastsquaremin.hpp"
    2827#include "Helpers/Info.hpp"
  • src/Parser/PcpParser.cpp

    r589112 r6e06bd  
    3131#include "Helpers/Log.hpp"
    3232#include "Helpers/Verbose.hpp"
    33 #include "LinearAlgebra/Matrix.hpp"
     33#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3434#include "molecule.hpp"
    3535#include "PcpParser.hpp"
     
    375375  DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl);
    376376
    377   const Matrix &domain = World::getInstance().getDomain().getM();
     377  const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
    378378  class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
    379379  if (!file->fail()) {
  • src/Shapes/ShapeOps.cpp

    r589112 r6e06bd  
    233233/************************* transform *****************/
    234234
    235 Transform_impl::Transform_impl(const Shape::impl_ptr &_arg, const Matrix &_transformation) :
     235Transform_impl::Transform_impl(const Shape::impl_ptr &_arg, const RealSpaceMatrix &_transformation) :
    236236  ShapeOpsBase_impl(_arg),transformation(_transformation)
    237237{
     
    254254
    255255Vector Transform_impl::translateOutNormal(const Vector& point){
    256   Matrix mat = transformation.invert().transpose();
     256  RealSpaceMatrix mat = transformation.invert().transpose();
    257257  return mat * point;
    258258}
     
    272272}
    273273
    274 Shape transform(const Shape &arg, const Matrix &transformation){
     274Shape transform(const Shape &arg, const RealSpaceMatrix &transformation){
    275275  Shape::impl_ptr impl = Shape::impl_ptr(new Transform_impl(getShapeImpl(arg),transformation));
    276276  return Shape(impl);
  • src/Shapes/ShapeOps.hpp

    r589112 r6e06bd  
    1111#include "Shapes/Shape.hpp"
    1212
    13 class Matrix;
     13class RealSpaceMatrix;
    1414
    1515Shape resize(const Shape&,double);
    1616Shape translate(const Shape&, const Vector&);
    1717Shape stretch(const Shape&, const Vector&);
    18 Shape transform(const Shape&,const Matrix&);
     18Shape transform(const Shape&,const RealSpaceMatrix&);
    1919
    2020#endif /* SHAPEOPS_HPP_ */
  • src/Shapes/ShapeOps_impl.hpp

    r589112 r6e06bd  
    1111#include "Shapes/Shape_impl.hpp"
    1212#include "LinearAlgebra/Vector.hpp"
    13 #include "LinearAlgebra/Matrix.hpp"
     13#include "LinearAlgebra/RealSpaceMatrix.hpp"
    1414
    1515#include <vector>
     
    8787{
    8888public:
    89   Transform_impl(const Shape::impl_ptr&, const Matrix&);
     89  Transform_impl(const Shape::impl_ptr&, const RealSpaceMatrix&);
    9090  virtual ~Transform_impl();
    9191protected:
     
    9797  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
    9898private:
    99   Matrix transformation;
    100   Matrix transformationInv;
     99  RealSpaceMatrix transformation;
     100  RealSpaceMatrix transformationInv;
    101101};
    102102
  • src/UIElements/CommandLineUI/CommandLineParser.cpp

    r589112 r6e06bd  
    412412    if ((iter->second)->Traits.hasShortForm()) {
    413413      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 "+
    416416          std::string(result[(iter->second)->Traits.getShortForm()])+"!");
    417417      result[(iter->second)->Traits.getShortForm()] = (iter->second)->getName();
  • src/UIElements/CommandLineUI/Query/BoxCommandLineQuery.cpp

    r589112 r6e06bd  
    2525#include "Helpers/Log.hpp"
    2626#include "Helpers/Verbose.hpp"
    27 #include "LinearAlgebra/Matrix.hpp"
     27#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2828
    2929CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
     
    3838  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    3939    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
    40     Matrix M;
     40    RealSpaceMatrix M;
    4141    M.set(0,0, temp.xx);
    4242    M.set(0,1, temp.yx);
  • src/UIElements/Dialog.cpp

    r589112 r6e06bd  
    2929class Box;
    3030class element;
    31 class Matrix;
     31class RealSpaceMatrix;
    3232class molecule;
    3333class Vector;
  • src/UIElements/Qt4/Pipe/BoxQtQueryPipe.cpp

    r589112 r6e06bd  
    2525
    2626#include "Helpers/MemDebug.hpp"
    27 #include "LinearAlgebra/Matrix.hpp"
     27#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2828#include "Box.hpp"
    2929
     
    3333  inputTable(_inputTable)
    3434{
    35   tmpM = new Matrix();
    36   tmpM->zero();
     35  tmpM = new RealSpaceMatrix();
     36  tmpM->setZero();
    3737}
    3838
  • src/UIElements/Qt4/Pipe/BoxQtQueryPipe.hpp

    r589112 r6e06bd  
    1515class Box;
    1616class QtDialog;
    17 class Matrix;
     17class RealSpaceMatrix;
    1818
    1919
     
    3232  QTableWidget *inputTable;
    3333
    34   Matrix *tmpM;
     34  RealSpaceMatrix *tmpM;
    3535};
    3636
  • src/UIElements/Qt4/Query/BoxQtQuery.cpp

    r589112 r6e06bd  
    2727#include "UIElements/Qt4/Pipe/BoxQtQueryPipe.hpp"
    2828
    29 #include "LinearAlgebra/Matrix.hpp"
     29#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3030#include "World.hpp"
    3131
     
    4747
    4848  // fill the box with current matrix
    49   const Matrix &domain = World::getInstance().getDomain().getM();
     49  const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
    5050  for (int i=0;i<3;i++)
    5151    for (int j=0;j<3;j++) {
  • src/UIElements/TextUI/Query/BoxTextQuery.cpp

    r589112 r6e06bd  
    2626#include "Helpers/Log.hpp"
    2727#include "Helpers/Verbose.hpp"
    28 #include "LinearAlgebra/Matrix.hpp"
     28#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2929
    3030
     
    4646    std::cin >> temp[i];
    4747  }
    48   Matrix M;
     48  RealSpaceMatrix M;
    4949  M.set(0,0, temp[0]);
    5050  M.set(0,1, temp[1]);
  • src/UIElements/TextUI/Query/VectorTextQuery.cpp

    r589112 r6e06bd  
    2727#include "Helpers/Verbose.hpp"
    2828#include "LinearAlgebra/Vector.hpp"
    29 #include "LinearAlgebra/Matrix.hpp"
     29#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3030#include "World.hpp"
    3131
     
    4040bool TextDialog::VectorTextQuery::handle() {
    4141  std::cout << getDescription() << std::endl;
    42   const Matrix &M = World::getInstance().getDomain().getM();
     42  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    4343  char coords[3] = {'x', 'y', 'z'};
    4444  for (int i=0;i<3;i++)
  • src/UIElements/TextUI/Query/VectorsTextQuery.cpp

    r589112 r6e06bd  
    2727#include "Helpers/Verbose.hpp"
    2828#include "LinearAlgebra/Vector.hpp"
    29 #include "LinearAlgebra/Matrix.hpp"
     29#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3030#include "World.hpp"
    3131
     
    4141  std::cout << getDescription() << std::endl;
    4242  char coords[3] = {'x', 'y', 'z'};
    43   const Matrix &M = World::getInstance().getDomain().getM();
     43  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
    4444  for (int i=0;i<3;i++)
    4545    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
  • src/World.cpp

    r589112 r6e06bd  
    3838#include "Helpers/Assert.hpp"
    3939#include "Box.hpp"
    40 #include "LinearAlgebra/Matrix.hpp"
     40#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4141#include "defs.hpp"
    4242
     
    100100}
    101101
    102 void World::setDomain(const Matrix &mat){
     102void World::setDomain(const RealSpaceMatrix &mat){
    103103  OBSERVE;
    104104  *cell_size = mat;
     
    108108{
    109109  OBSERVE;
    110   Matrix M = ReturnFullMatrixforSymmetric(matrix);
     110  RealSpaceMatrix M = ReturnFullMatrixforSymmetric(matrix);
    111111  cell_size->setM(M);
    112112}
     
    747747{
    748748  cell_size = new Box;
    749   Matrix domain;
     749  RealSpaceMatrix domain;
    750750  domain.at(0,0) = 20;
    751751  domain.at(1,1) = 20;
  • src/World.hpp

    r589112 r6e06bd  
    4141class config;
    4242class ManipulateAtomsProcess;
    43 class Matrix;
     43class RealSpaceMatrix;
    4444class molecule;
    4545class MoleculeDescriptor;
     
    147147   * Matrix needs to be symmetric
    148148   */
    149   void setDomain(const Matrix &mat);
     149  void setDomain(const RealSpaceMatrix &mat);
    150150
    151151  /**
  • src/analysis_correlation.cpp

    r589112 r6e06bd  
    3333#include "triangleintersectionlist.hpp"
    3434#include "LinearAlgebra/Vector.hpp"
    35 #include "LinearAlgebra/Matrix.hpp"
     35#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3636#include "Helpers/Verbose.hpp"
    3737#include "World.hpp"
     
    145145  outmap = new PairCorrelationMap;
    146146  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();
    149149    DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    150150    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     
    244244  outmap = new CorrelationToPointMap;
    245245  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();
    248248    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    249249    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     
    342342  BoundaryTriangleSet *ShortestTriangle = NULL;
    343343  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();
    346346    DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    347347    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
  • src/atom_atominfo.hpp

    r589112 r6e06bd  
    2626class AtomInfo;
    2727class element;
    28 class Matrix;
     28class RealSpaceMatrix;
    2929
    3030/********************************************** declarations *******************************/
  • src/boundary.cpp

    r589112 r6e06bd  
    4040#include "World.hpp"
    4141#include "LinearAlgebra/Plane.hpp"
    42 #include "LinearAlgebra/Matrix.hpp"
     42#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4343#include "Box.hpp"
    4444
     
    792792  int N[NDIM];
    793793  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();
    797797  Vector AtomTranslations;
    798798  Vector FillerTranslations;
     
    944944  int N[NDIM];
    945945  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();
    949949  Vector AtomTranslations;
    950950  Vector FillerTranslations;
  • src/config.cpp

    r589112 r6e06bd  
    3939#include "ThermoStatContainer.hpp"
    4040#include "World.hpp"
    41 #include "LinearAlgebra/Matrix.hpp"
     41#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4242#include "Box.hpp"
    4343
     
    637637{
    638638  bool result = true;
    639   const Matrix &domain = World::getInstance().getDomain().getM();
     639  const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
    640640  ofstream * const output = new ofstream(filename, ios::out);
    641641  if (output != NULL) {
  • src/ellipsoid.cpp

    r589112 r6e06bd  
    3434#include "tesselation.hpp"
    3535#include "LinearAlgebra/Vector.hpp"
    36 #include "LinearAlgebra/Matrix.hpp"
     36#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3737#include "Helpers/Verbose.hpp"
    3838
     
    4848  Vector helper, RefPoint;
    4949  double distance = -1.;
    50   Matrix Matrix;
     50  RealSpaceMatrix Matrix;
    5151  double InverseLength[3];
    5252  double psi,theta,phi; // euler angles in ZX'Z'' convention
  • src/molecule.cpp

    r589112 r6e06bd  
    4343#include "tesselation.hpp"
    4444#include "LinearAlgebra/Vector.hpp"
    45 #include "LinearAlgebra/Matrix.hpp"
     45#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4646#include "World.hpp"
    4747#include "Box.hpp"
     
    316316  Vector Orthovector1, Orthovector2;  // temporary vectors in coordination construction
    317317  Vector InBondvector;    // vector in direction of *Bond
    318   const Matrix &matrix =  World::getInstance().getDomain().getM();
     318  const RealSpaceMatrix &matrix =  World::getInstance().getDomain().getM();
    319319  bond *Binder = NULL;
    320320
     
    778778void molecule::SetBoxDimension(Vector *dim)
    779779{
    780   Matrix domain;
     780  RealSpaceMatrix domain;
    781781  for(int i =0; i<NDIM;++i)
    782782    domain.at(i,i) = dim->at(i);
     
    862862bool molecule::CheckBounds(const Vector *x) const
    863863{
    864   const Matrix &domain = World::getInstance().getDomain().getM();
     864  const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();
    865865  bool result = true;
    866866  for (int i=0;i<NDIM;i++) {
  • src/molecule_fragmentation.cpp

    r589112 r6e06bd  
    3434#include "periodentafel.hpp"
    3535#include "World.hpp"
    36 #include "LinearAlgebra/Matrix.hpp"
     36#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3737#include "Box.hpp"
    3838#include "stackclass.hpp"
     
    17391739  atom *Walker = NULL;
    17401740  atom *OtherWalker = NULL;
    1741   Matrix matrix = World::getInstance().getDomain().getM();
     1741  RealSpaceMatrix matrix = World::getInstance().getDomain().getM();
    17421742  enum Shading *ColorList = NULL;
    17431743  double tmp;
  • src/molecule_geometry.cpp

    r589112 r6e06bd  
    2424#include "Helpers/Verbose.hpp"
    2525#include "LinearAlgebra/Line.hpp"
    26 #include "LinearAlgebra/Matrix.hpp"
     26#include "LinearAlgebra/RealSpaceMatrix.hpp"
    2727#include "LinearAlgebra/Plane.hpp"
    2828
     
    166166{
    167167  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();
    169169  (*a) *= M;
    170170  return a;
     
    287287void molecule::DeterminePeriodicCenter(Vector &center)
    288288{
    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();
    291291  double tmp;
    292292  bool flag;
  • src/molecule_graph.cpp

    r589112 r6e06bd  
    3636#include "Helpers/fast_functions.hpp"
    3737#include "Helpers/Assert.hpp"
    38 #include "LinearAlgebra/Matrix.hpp"
     38#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3939#include "Box.hpp"
    4040#include "stackclass.hpp"
  • src/moleculelist.cpp

    r589112 r6e06bd  
    4040#include "tesselation.hpp"
    4141#include "Helpers/Assert.hpp"
    42 #include "LinearAlgebra/Matrix.hpp"
     42#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4343#include "Box.hpp"
    4444#include "stackclass.hpp"
     
    487487  int FragmentCounter = 0;
    488488  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;
    491491
    492492  // store the fragments as config and as xyz
     
    629629  // center at set box dimensions
    630630  mol->CenterEdge(&center);
    631   Matrix domain;
     631  RealSpaceMatrix domain;
    632632  for(int i =0;i<NDIM;++i)
    633633    domain.at(i,i) = center[i];
  • src/tesselationhelpers.cpp

    r589112 r6e06bd  
    3838#include "Helpers/Verbose.hpp"
    3939#include "LinearAlgebra/Plane.hpp"
    40 #include "LinearAlgebra/Matrix.hpp"
     40#include "LinearAlgebra/RealSpaceMatrix.hpp"
    4141
    4242void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
    4343{
    4444        Info FunctionInfo(__func__);
    45   Matrix mat;
     45  RealSpaceMatrix mat;
    4646  double m11, m12, m13, m14;
    4747
  • src/unittests/BoxUnittest.cpp

    r589112 r6e06bd  
    2929
    3030#include "LinearAlgebra/Vector.hpp"
    31 #include "LinearAlgebra/Matrix.hpp"
     31#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3232#include "Box.hpp"
    3333#include "Helpers/Assert.hpp"
     
    4040void BoxUnittest::setUp(){
    4141  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;
    4646  invertible->diagonal() = Vector(1,2,3);
    47   uninvertible = new Matrix;
     47  uninvertible = new RealSpaceMatrix;
    4848  uninvertible->column(0) = Vector(1,0,1);
    4949  uninvertible->column(2) = Vector(1,0,1);
    5050
    51   Matrix boxMat;
     51  RealSpaceMatrix boxMat;
    5252  unitBox = new Box;
    5353  stretchedBox1 = new Box;
    54   boxMat.one();
     54  boxMat.setIdentity();
    5555  boxMat.diagonal() = Vector(1,2,3);
    5656  stretchedBox1->setM(boxMat);
    5757
    5858  stretchedBox2 = new Box;
    59   boxMat.one();
     59  boxMat.setIdentity();
    6060  boxMat.diagonal() = Vector(2,3,1);
    6161  stretchedBox2->setM(boxMat);
    6262
    6363  stretchedBox3 = new Box;
    64   boxMat.one();
     64  boxMat.setIdentity();
    6565  boxMat.diagonal() = Vector(3,1,2);
    6666  stretchedBox3->setM(boxMat);
    6767
    6868  stretchedBox4 = new Box;
    69   boxMat.one();
     69  boxMat.setIdentity();
    7070  boxMat.diagonal() = Vector(2,2,2);
    7171  stretchedBox4->setM(boxMat);
    7272
    7373  tiltedBox1 = new Box;
    74   boxMat.one();
     74  boxMat.setIdentity();
    7575  boxMat.column(0) = Vector(1,0,1);
    7676  tiltedBox1->setM(boxMat);
    7777
    7878  tiltedBox2 = new Box;
    79   boxMat.one();
     79  boxMat.setIdentity();
    8080  boxMat.column(0) = Vector(1,1,1);
    8181  tiltedBox2->setM(boxMat);
    8282
    8383  tiltedBox3 = new Box;
    84   boxMat.one();
     84  boxMat.setIdentity();
    8585  boxMat.column(1) = Vector(0,1,1);
    8686  tiltedBox3->setM(boxMat);
    8787
    8888  tiltedBox4 = new Box;
    89   boxMat.one();
     89  boxMat.setIdentity();
    9090  boxMat.column(0) = Vector(1,1,1);
    9191  boxMat.column(1) = Vector(0,1,1);
  • src/unittests/BoxUnittest.hpp

    r589112 r6e06bd  
    1111#include <cppunit/extensions/HelperMacros.h>
    1212
    13 class Matrix;
     13class RealSpaceMatrix;
    1414class Box;
    1515
     
    3838  void BoundaryMixedTest();
    3939
    40   Matrix *unit;
    41   Matrix *zero;
    42   Matrix *invertible;
    43   Matrix *uninvertible;
     40  RealSpaceMatrix *unit;
     41  RealSpaceMatrix *zero;
     42  RealSpaceMatrix *invertible;
     43  RealSpaceMatrix *uninvertible;
    4444
    4545  Box *unitBox;
  • src/unittests/Makefile.am

    r589112 r6e06bd  
    2222  CountBondsUnitTest \
    2323  FormulaUnittest \
    24   GSLMatrixSymmetricUnitTest \
    25   GSLMatrixUnitTest \
    26   GSLVectorUnitTest \
    2724  InfoUnitTest \
    2825  LinearSystemOfEquationsUnitTest \
     
    3229  LogUnitTest \
    3330  manipulateAtomsTest \
     31  MatrixContentSymmetricUnitTest \
     32  MatrixContentUnitTest \
    3433  MatrixUnittest \
    3534  MenuDescriptionUnitTest \
     
    4645  Tesselation_BoundaryTriangleUnitTest \
    4746  Tesselation_InOutsideUnitTest \
     47  VectorContentUnitTest \
    4848  VectorUnitTest
    4949 
     
    8282  CountBondsUnitTest.cpp \
    8383  FormulaUnittest.cpp \
    84   gslmatrixsymmetricunittest.cpp \
    85   gslmatrixunittest.cpp \
    86   gslvectorunittest.cpp \
    8784  infounittest.cpp \
    8885  linearsystemofequationsunittest.cpp \
     
    9188  listofbondsunittest.cpp \
    9289  logunittest.cpp \
     90  MatrixContentSymmetricUnittest.cpp \
     91  MatrixContentUnittest.cpp \
    9392  MatrixUnittest.cpp \
    9493  manipulateAtomsTest.cpp \
     
    106105  tesselation_boundarytriangleunittest.cpp \
    107106  tesselation_insideoutsideunittest.cpp \
     107  VectorContentUnittest.cpp \
    108108  vectorunittest.cpp
    109109
     
    122122  CountBondsUnitTest.hpp \
    123123  FormulaUnittest.hpp \
    124   gslmatrixsymmetricunittest.hpp \
    125   gslmatrixunittest.hpp \
    126   gslvectorunittest.hpp \
    127124  infounittest.hpp \
    128125  linearsystemofequationsunittest.hpp \
     
    132129  logunittest.hpp \
    133130  manipulateAtomsTest.hpp \
     131  MatrixContentSymmetricUnittest.hpp \
     132  MatrixContentUnittest.hpp \
    134133  MatrixUnittest.hpp \
    135134  MenuDescriptionUnitTest.hpp \
     
    145144  tesselation_boundarytriangleunittest.hpp \
    146145  tesselation_insideoutsideunittest.hpp \
     146  VectorContentUnittest.hpp \
    147147  vectorunittest.hpp
    148148 
     
    187187FormulaUnittest_LDADD = ${ALLLIBS}
    188188
    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}
     189MatrixContentSymmetricUnitTest_SOURCES = UnitTestMain.cpp MatrixContentSymmetricUnittest.cpp MatrixContentSymmetricUnittest
     190MatrixContentSymmetricUnitTest_LDADD = ${ALLLIBS}
     191
     192MatrixContentUnitTest_SOURCES = UnitTestMain.cpp MatrixContentUnittest.cpp MatrixContentUnittest.hpp
     193MatrixContentUnitTest_LDADD = ${ALLLIBS}
    197194
    198195InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp
     
    262259TestRunner_LDADD = ${UILIBS} ${ALLLIBS}
    263260
     261VectorContentUnitTest_SOURCES = UnitTestMain.cpp VectorContentUnittest.cpp VectorContentUnittest.hpp
     262VectorContentUnitTest_LDADD = ${ALLLIBS}
     263
    264264VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
    265265VectorUnitTest_LDADD = ${ALLLIBS}
  • src/unittests/MatrixUnittest.cpp

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

    r589112 r6e06bd  
    1111#include <cppunit/extensions/HelperMacros.h>
    1212
    13 class Matrix;
     13class RealSpaceMatrix;
    1414
    1515class MatrixUnittest : public CppUnit::TestFixture
     
    3939  void VecMultTest();
    4040
    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;
    5050};
    5151
  • src/unittests/vectorunittest.cpp

    r589112 r6e06bd  
    3131#include "LinearAlgebra/Plane.hpp"
    3232#include "Exceptions/LinearDependenceException.hpp"
    33 #include "LinearAlgebra/Matrix.hpp"
     33#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3434
    3535#ifdef HAVE_TESTRUNNER
Note: See TracChangeset for help on using the changeset viewer.