Ignore:
Timestamp:
Oct 27, 2009, 4:11:22 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
069034
Parents:
55a71b
Message:

Huge refactoring to make const what is const (ticket #38), continued.

  • too many changes because of too many cross-references to be able to list them up here.
  • NOTE that "make check" runs fine and did catch several error.
  • note that we had to use const_iterator several times when the map, ... was declared const.
  • at times we changed an allocated LinkedCell LCList(...) into

const LinkedCell *LCList;
LCList = new LinkedCell(...);

  • also mutable (see ticket #5) was used, e.g. for molecule::InternalPointer (PointCloud changes are allowed, because they are just accounting).

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/vector.cpp

    r55a71b ra9b2a0a  
    2121/** Constructor of class vector.
    2222 */
    23 Vector::Vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
     23Vector::Vector(const double x1, const double x2, const double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
    2424
    2525/** Desctructor of class vector.
     
    3131 * \return \f$| x - y |^2\f$
    3232 */
    33 double Vector::DistanceSquared(const Vector *y) const
     33double Vector::DistanceSquared(const Vector * const y) const
    3434{
    3535  double res = 0.;
     
    4343 * \return \f$| x - y |\f$
    4444 */
    45 double Vector::Distance(const Vector *y) const
     45double Vector::Distance(const Vector * const y) const
    4646{
    4747  double res = 0.;
     
    5656 * \return \f$| x - y |\f$
    5757 */
    58 double Vector::PeriodicDistance(const Vector *y, const double *cell_size) const
     58double Vector::PeriodicDistance(const Vector * const y, const double * const cell_size) const
    5959{
    6060  double res = Distance(y), tmp, matrix[NDIM*NDIM];
     
    9494 * \return \f$| x - y |^2\f$
    9595 */
    96 double Vector::PeriodicDistanceSquared(const Vector *y, const double *cell_size) const
     96double Vector::PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const
    9797{
    9898  double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
     
    131131 * Tries to translate a vector into each adjacent neighbouring cell.
    132132 */
    133 void Vector::KeepPeriodic(ofstream *out, double *matrix)
     133void Vector::KeepPeriodic(ofstream *out, const double * const matrix)
    134134{
    135135//  int N[NDIM];
     
    162162 * \return \f$\langle x, y \rangle\f$
    163163 */
    164 double Vector::ScalarProduct(const Vector *y) const
     164double Vector::ScalarProduct(const Vector * const y) const
    165165{
    166166  double res = 0.;
     
    177177 *  \return \f$ x \times y \f&
    178178 */
    179 void Vector::VectorProduct(const Vector *y)
     179void Vector::VectorProduct(const Vector * const y)
    180180{
    181181  Vector tmp;
     
    184184  tmp.x[2] = x[0]* (y->x[1]) - x[1]* (y->x[0]);
    185185  this->CopyVector(&tmp);
    186 
    187186};
    188187
     
    192191 * \return \f$\langle x, y \rangle\f$
    193192 */
    194 void Vector::ProjectOntoPlane(const Vector *y)
     193void Vector::ProjectOntoPlane(const Vector * const y)
    195194{
    196195  Vector tmp;
     
    217216 * \return true -  \a this contains intersection point on return, false - line is parallel to plane
    218217 */
    219 bool Vector::GetIntersectionWithPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset, Vector *Origin, Vector *LineVector)
     218bool Vector::GetIntersectionWithPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector)
    220219{
    221220  double factor;
     
    264263 * \return distance to plane
    265264 */
    266 double Vector::DistanceToPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset)
     265double Vector::DistanceToPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
    267266{
    268267  Vector temp;
     
    292291 * \return true - \a this will contain the intersection on return, false - lines are parallel
    293292 */
    294 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *PlaneNormal)
     293bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal)
    295294{
    296295  bool result = true;
     
    375374 * \param *y array to second vector
    376375 */
    377 void Vector::ProjectIt(const Vector *y)
     376void Vector::ProjectIt(const Vector * const y)
    378377{
    379378  Vector helper(*y);
     
    386385 * \return Vector
    387386 */
    388 Vector Vector::Projection(const Vector *y) const
     387Vector Vector::Projection(const Vector * const y) const
    389388{
    390389  Vector helper(*y);
     
    435434/** Zeros all components of this vector.
    436435 */
    437 void Vector::One(double one)
     436void Vector::One(const double one)
    438437{
    439438  for (int i=NDIM;i--;)
     
    443442/** Initialises all components of this vector.
    444443 */
    445 void Vector::Init(double x1, double x2, double x3)
     444void Vector::Init(const double x1, const double x2, const double x3)
    446445{
    447446  x[0] = x1;
     
    469468 * @return true - vector is normalized, false - vector is not
    470469 */
    471 bool Vector::IsNormalTo(const Vector *normal) const
     470bool Vector::IsNormalTo(const Vector * const normal) const
    472471{
    473472  if (ScalarProduct(normal) < MYEPSILON)
     
    481480 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    482481 */
    483 double Vector::Angle(const Vector *y) const
     482double Vector::Angle(const Vector * const y) const
    484483{
    485484  double norm1 = Norm(), norm2 = y->Norm();
     
    500499 * \param alpha rotation angle in radian
    501500 */
    502 void Vector::RotateVector(const Vector *axis, const double alpha)
     501void Vector::RotateVector(const Vector * const axis, const double alpha)
    503502{
    504503  Vector a,y;
     
    656655 * \param *factor pointer to scaling factor
    657656 */
    658 void Vector::Scale(double **factor)
     657void Vector::Scale(const double ** const factor)
    659658{
    660659  for (int i=NDIM;i--;)
     
    662661};
    663662
    664 void Vector::Scale(double *factor)
     663void Vector::Scale(const double * const factor)
    665664{
    666665  for (int i=NDIM;i--;)
     
    668667};
    669668
    670 void Vector::Scale(double factor)
     669void Vector::Scale(const double factor)
    671670{
    672671  for (int i=NDIM;i--;)
     
    677676 * \param trans[] translation vector.
    678677 */
    679 void Vector::Translate(const Vector *trans)
     678void Vector::Translate(const Vector * const trans)
    680679{
    681680  for (int i=NDIM;i--;)
     
    687686 * \param *Minv inverse matrix
    688687 */
    689 void Vector::WrapPeriodically(const double *M, const double *Minv)
     688void Vector::WrapPeriodically(const double * const M, const double * const Minv)
    690689{
    691690  MatrixMultiplication(Minv);
     
    704703 * \param *matrix NDIM_NDIM array
    705704 */
    706 void Vector::MatrixMultiplication(const double *M)
     705void Vector::MatrixMultiplication(const double * const M)
    707706{
    708707  Vector C;
     
    719718 * \param *matrix NDIM_NDIM array
    720719 */
    721 double * Vector::InverseMatrix(double *A)
     720double * Vector::InverseMatrix( const double * const A)
    722721{
    723722  double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     
    746745 * \param *matrix NDIM_NDIM array
    747746 */
    748 void Vector::InverseMatrixMultiplication(const double *A)
     747void Vector::InverseMatrixMultiplication(const double * const A)
    749748{
    750749  Vector C;
     
    786785 * \param *factors three-component vector with the factor for each given vector
    787786 */
    788 void Vector::LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors)
     787void Vector::LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors)
    789788{
    790789  for(int i=NDIM;i--;)
     
    795794 * \param n[] normal vector of mirror plane.
    796795 */
    797 void Vector::Mirror(const Vector *n)
     796void Vector::Mirror(const Vector * const n)
    798797{
    799798  double projection;
     
    817816 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    818817 */
    819 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2, const Vector *y3)
     818bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2, const Vector * const y3)
    820819{
    821820  Vector x1, x2;
     
    853852 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    854853 */
    855 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2)
     854bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2)
    856855{
    857856  Vector x1,x2;
     
    884883 * \return true - success, false - vector is zero
    885884 */
    886 bool Vector::MakeNormalVector(const Vector *y1)
     885bool Vector::MakeNormalVector(const Vector * const y1)
    887886{
    888887  bool result = false;
     
    904903 * \return true - success, false - failure (null vector given)
    905904 */
    906 bool Vector::GetOneNormalVector(const Vector *GivenVector)
     905bool Vector::GetOneNormalVector(const Vector * const GivenVector)
    907906{
    908907  int Components[NDIM]; // contains indices of non-zero components
     
    950949 * \return scaling parameter for this vector
    951950 */
    952 double Vector::CutsPlaneAt(Vector *A, Vector *B, Vector *C)
     951double Vector::CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const
    953952{
    954953//  cout << Verbose(3) << "For comparison: ";
     
    965964 * \return true if success, false if failed due to linear dependency
    966965 */
    967 bool Vector::LSQdistance(Vector **vectors, int num)
     966bool Vector::LSQdistance(const Vector **vectors, int num)
    968967{
    969968  int j;
     
    10471046 * \param *y vector
    10481047 */
    1049 void Vector::AddVector(const Vector *y)
     1048void Vector::AddVector(const Vector * const y)
    10501049{
    10511050  for (int i=NDIM;i--;)
     
    10561055 * \param *y vector
    10571056 */
    1058 void Vector::SubtractVector(const Vector *y)
     1057void Vector::SubtractVector(const Vector * const y)
    10591058{
    10601059  for (int i=NDIM;i--;)
     
    10651064 * \param *y vector
    10661065 */
    1067 void Vector::CopyVector(const Vector *y)
     1066void Vector::CopyVector(const Vector * const y)
    10681067{
    10691068  for (int i=NDIM;i--;)
     
    10741073 * \param y vector
    10751074 */
    1076 void Vector::CopyVector(const Vector y)
     1075void Vector::CopyVector(const Vector &y)
    10771076{
    10781077  for (int i=NDIM;i--;)
     
    10851084 * \param check whether bounds shall be checked (true) or not (false)
    10861085 */
    1087 void Vector::AskPosition(double *cell_size, bool check)
     1086void Vector::AskPosition(const double * const cell_size, const bool check)
    10881087{
    10891088  char coords[3] = {'x','y','z'};
     
    11131112 * \bug this is not yet working properly
    11141113 */
    1115 bool Vector::SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c)
     1114bool Vector::SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c)
    11161115{
    11171116  double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C;
     
    12761275 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    12771276 */
    1278 bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const
     1277bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
    12791278{
    12801279  Vector a;
Note: See TracChangeset for help on using the changeset viewer.