Ignore:
Timestamp:
Aug 6, 2008, 9:02:01 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
67f102
Parents:
0a08df
Message:

Rename of class vector to Vector to avoid conflict with vector from STL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/vector.cpp

    r0a08df r8f8621  
    1212/** Constructor of class vector.
    1313 */
    14 vector::vector() { x[0] = x[1] = x[2] = 0.; };
     14Vector::Vector() { x[0] = x[1] = x[2] = 0.; };
    1515
    1616/** Constructor of class vector.
    1717 */
    18 vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
     18Vector::Vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
    1919
    2020/** Desctructor of class vector.
    2121 */
    22 vector::~vector() {};
     22Vector::~Vector() {};
    2323
    2424/** Calculates distance between this and another vector.
     
    2626 * \return \f$| x - y |^2\f$
    2727 */
    28 double vector::Distance(const vector *y) const
     28double Vector::Distance(const Vector *y) const
    2929{
    3030  double res = 0.;
     
    3939 * \return \f$| x - y |^2\f$
    4040 */
    41 double vector::PeriodicDistance(const vector *y, const double *cell_size) const
     41double Vector::PeriodicDistance(const Vector *y, const double *cell_size) const
    4242{
    4343  double res = Distance(y), tmp, matrix[NDIM*NDIM];
    44   vector Shiftedy, TranslationVector;
     44  Vector Shiftedy, TranslationVector;
    4545  int N[NDIM];
    4646  matrix[0] = cell_size[0];
     
    7676 * Tries to translate a vector into each adjacent neighbouring cell.
    7777 */
    78 void vector::KeepPeriodic(ofstream *out, double *matrix)
     78void Vector::KeepPeriodic(ofstream *out, double *matrix)
    7979{
    8080//  int N[NDIM];
    8181//  bool flag = false;
    8282  //vector Shifted, TranslationVector;
    83   vector TestVector;
     83  Vector TestVector;
    8484//  *out << Verbose(1) << "Begin of KeepPeriodic." << endl;
    8585//  *out << Verbose(2) << "Vector is: ";
     
    107107 * \return \f$\langle x, y \rangle\f$
    108108 */
    109 double vector::ScalarProduct(const vector *y) const
     109double Vector::ScalarProduct(const Vector *y) const
    110110{
    111111  double res = 0.;
     
    119119 * \return \f$\langle x, y \rangle\f$
    120120 */
    121 void vector::ProjectOntoPlane(const vector *y)
    122 {
    123   vector tmp;
     121void Vector::ProjectOntoPlane(const Vector *y)
     122{
     123  Vector tmp;
    124124  tmp.CopyVector(y);
    125125  tmp.Scale(Projection(y));
     
    131131 * \return \f$\langle x, y \rangle\f$
    132132 */
    133 double vector::Projection(const vector *y) const
     133double Vector::Projection(const Vector *y) const
    134134{
    135135  return (ScalarProduct(y));
     
    139139 * \return \f$|x|\f$
    140140 */
    141 double vector::Norm() const
     141double Vector::Norm() const
    142142{
    143143  double res = 0.;
     
    149149/** Normalizes this vector.
    150150 */
    151 void vector::Normalize()
     151void Vector::Normalize()
    152152{
    153153  double res = 0.;
     
    160160/** Zeros all components of this vector.
    161161 */
    162 void vector::Zero()
     162void Vector::Zero()
    163163{
    164164  for (int i=NDIM;i--;)
     
    168168/** Zeros all components of this vector.
    169169 */
    170 void vector::One(double one)
     170void Vector::One(double one)
    171171{
    172172  for (int i=NDIM;i--;)
     
    176176/** Initialises all components of this vector.
    177177 */
    178 void vector::Init(double x1, double x2, double x3)
     178void Vector::Init(double x1, double x2, double x3)
    179179{
    180180  x[0] = x1;
     
    187187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    188188 */
    189 double vector::Angle(vector *y) const
     189double Vector::Angle(Vector *y) const
    190190{
    191191  return acos(this->ScalarProduct(y)/Norm()/y->Norm());
     
    196196 * \param alpha rotation angle in radian
    197197 */
    198 void vector::RotateVector(const vector *axis, const double alpha)
    199 {
    200   vector a,y;
     198void Vector::RotateVector(const Vector *axis, const double alpha)
     199{
     200  Vector a,y;
    201201  // normalise this vector with respect to axis
    202202  a.CopyVector(this);
     
    220220 * \return lhs + a
    221221 */
    222 vector& operator+=(vector& a, const vector& b)
     222Vector& operator+=(Vector& a, const Vector& b)
    223223{
    224224  a.AddVector(&b);
     
    230230 * \return lhs.x[i] * m
    231231 */
    232 vector& operator*=(vector& a, const double m)
     232Vector& operator*=(Vector& a, const double m)
    233233{
    234234  a.Scale(m);
     
    241241 * \return a + b
    242242 */
    243 vector& operator+(const vector& a, const vector& b)
    244 {
    245   vector *x = new vector;
     243Vector& operator+(const Vector& a, const Vector& b)
     244{
     245  Vector *x = new Vector;
    246246  x->CopyVector(&a);
    247247  x->AddVector(&b);
     
    254254 * \return a + b
    255255 */
    256 vector& operator*(const vector& a, const double m)
    257 {
    258   vector *x = new vector;
     256Vector& operator*(const Vector& a, const double m)
     257{
     258  Vector *x = new Vector;
    259259  x->CopyVector(&a);
    260260  x->Scale(m);
     
    266266 * \param *out output stream
    267267 */
    268 bool vector::Output(ofstream *out) const
     268bool Vector::Output(ofstream *out) const
    269269{
    270270  if (out != NULL) {
     
    281281};
    282282
    283 ofstream& operator<<(ofstream& ost,vector& m)
     283ofstream& operator<<(ofstream& ost,Vector& m)
    284284{
    285285        m.Output(&ost);
     
    290290 * \param *factor pointer to scaling factor
    291291 */
    292 void vector::Scale(double **factor)
     292void Vector::Scale(double **factor)
    293293{
    294294  for (int i=NDIM;i--;)
     
    296296};
    297297
    298 void vector::Scale(double *factor)
     298void Vector::Scale(double *factor)
    299299{
    300300  for (int i=NDIM;i--;)
     
    302302};
    303303
    304 void vector::Scale(double factor)
     304void Vector::Scale(double factor)
    305305{
    306306  for (int i=NDIM;i--;)
     
    311311 * \param trans[] translation vector.
    312312 */
    313 void vector::Translate(const vector *trans)
     313void Vector::Translate(const Vector *trans)
    314314{
    315315  for (int i=NDIM;i--;)
     
    320320 * \param *matrix NDIM_NDIM array
    321321 */
    322 void vector::MatrixMultiplication(double *M)
    323 {
    324   vector C;
     322void Vector::MatrixMultiplication(double *M)
     323{
     324  Vector C;
    325325  // do the matrix multiplication
    326326  C.x[0] = M[0]*x[0]+M[3]*x[1]+M[6]*x[2];
     
    335335 * \param *matrix NDIM_NDIM array
    336336 */
    337 void vector::InverseMatrixMultiplication(double *A)
    338 {
    339   vector C;
     337void Vector::InverseMatrixMultiplication(double *A)
     338{
     339  Vector C;
    340340  double B[NDIM*NDIM];
    341341  double detA = RDET3(A);
     
    375375 * \param *factors three-component vector with the factor for each given vector
    376376 */
    377 void vector::LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors)
     377void Vector::LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors)
    378378{
    379379  for(int i=NDIM;i--;)
     
    384384 * \param n[] normal vector of mirror plane.
    385385 */
    386 void vector::Mirror(const vector *n)
     386void Vector::Mirror(const Vector *n)
    387387{
    388388  double projection;
     
    406406 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    407407 */
    408 bool vector::MakeNormalVector(const vector *y1, const vector *y2, const vector *y3)
    409 {
    410   vector x1, x2;
     408bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2, const Vector *y3)
     409{
     410  Vector x1, x2;
    411411
    412412  x1.CopyVector(y1);
     
    442442 * \return true - success, vectors are linear independent, false - failure due to linear dependency
    443443 */
    444 bool vector::MakeNormalVector(const vector *y1, const vector *y2)
    445 {
    446   vector x1,x2;
     444bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2)
     445{
     446  Vector x1,x2;
    447447  x1.CopyVector(y1);
    448448  x2.CopyVector(y2);
     
    472472 * \return true - success, false - vector is zero
    473473 */
    474 bool vector::MakeNormalVector(const vector *y1)
     474bool Vector::MakeNormalVector(const Vector *y1)
    475475{
    476476        bool result = false;
    477   vector x1;
     477  Vector x1;
    478478  x1.CopyVector(y1);
    479479  x1.Scale(x1.Projection(this));
     
    491491 * \return true - success, false - failure (null vector given)
    492492 */
    493 bool vector::GetOneNormalVector(const vector *GivenVector)
     493bool Vector::GetOneNormalVector(const Vector *GivenVector)
    494494{
    495495  int Components[NDIM]; // contains indices of non-zero components
     
    537537 * \return scaling parameter for this vector
    538538 */
    539 double vector::CutsPlaneAt(vector *A, vector *B, vector *C)
     539double Vector::CutsPlaneAt(Vector *A, Vector *B, Vector *C)
    540540{
    541541//  cout << Verbose(3) << "For comparison: ";
     
    552552 * \return true if success, false if failed due to linear dependency
    553553 */
    554 bool vector::LSQdistance(vector **vectors, int num)
     554bool Vector::LSQdistance(Vector **vectors, int num)
    555555{
    556556        int j;
     
    634634 * \param *y vector
    635635 */
    636 void vector::AddVector(const vector *y)
     636void Vector::AddVector(const Vector *y)
    637637{
    638638  for (int i=NDIM;i--;)
     
    643643 * \param *y vector
    644644 */
    645 void vector::SubtractVector(const vector *y)
     645void Vector::SubtractVector(const Vector *y)
    646646{
    647647  for (int i=NDIM;i--;)
     
    652652 * \param *y vector
    653653 */
    654 void vector::CopyVector(const vector *y)
     654void Vector::CopyVector(const Vector *y)
    655655{
    656656  for (int i=NDIM;i--;)
     
    663663 * \param check whether bounds shall be checked (true) or not (false)
    664664 */
    665 void vector::AskPosition(double *cell_size, bool check)
     665void Vector::AskPosition(double *cell_size, bool check)
    666666{
    667667  char coords[3] = {'x','y','z'};
     
    691691 * \bug this is not yet working properly
    692692 */
    693 bool vector::SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c)
     693bool Vector::SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c)
    694694{
    695695  double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C;
Note: See TracChangeset for help on using the changeset viewer.