Changeset 8f8621 for molecuilder/src/vector.cpp
- Timestamp:
- Aug 6, 2008, 9:02:01 AM (17 years ago)
- Children:
- 67f102
- Parents:
- 0a08df
- File:
-
- 1 edited
-
molecuilder/src/vector.cpp (modified) (39 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
r0a08df r8f8621 12 12 /** Constructor of class vector. 13 13 */ 14 vector::vector() { x[0] = x[1] = x[2] = 0.; };14 Vector::Vector() { x[0] = x[1] = x[2] = 0.; }; 15 15 16 16 /** Constructor of class vector. 17 17 */ 18 vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };18 Vector::Vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; }; 19 19 20 20 /** Desctructor of class vector. 21 21 */ 22 vector::~vector() {};22 Vector::~Vector() {}; 23 23 24 24 /** Calculates distance between this and another vector. … … 26 26 * \return \f$| x - y |^2\f$ 27 27 */ 28 double vector::Distance(const vector *y) const28 double Vector::Distance(const Vector *y) const 29 29 { 30 30 double res = 0.; … … 39 39 * \return \f$| x - y |^2\f$ 40 40 */ 41 double vector::PeriodicDistance(const vector *y, const double *cell_size) const41 double Vector::PeriodicDistance(const Vector *y, const double *cell_size) const 42 42 { 43 43 double res = Distance(y), tmp, matrix[NDIM*NDIM]; 44 vector Shiftedy, TranslationVector;44 Vector Shiftedy, TranslationVector; 45 45 int N[NDIM]; 46 46 matrix[0] = cell_size[0]; … … 76 76 * Tries to translate a vector into each adjacent neighbouring cell. 77 77 */ 78 void vector::KeepPeriodic(ofstream *out, double *matrix)78 void Vector::KeepPeriodic(ofstream *out, double *matrix) 79 79 { 80 80 // int N[NDIM]; 81 81 // bool flag = false; 82 82 //vector Shifted, TranslationVector; 83 vector TestVector;83 Vector TestVector; 84 84 // *out << Verbose(1) << "Begin of KeepPeriodic." << endl; 85 85 // *out << Verbose(2) << "Vector is: "; … … 107 107 * \return \f$\langle x, y \rangle\f$ 108 108 */ 109 double vector::ScalarProduct(const vector *y) const109 double Vector::ScalarProduct(const Vector *y) const 110 110 { 111 111 double res = 0.; … … 119 119 * \return \f$\langle x, y \rangle\f$ 120 120 */ 121 void vector::ProjectOntoPlane(const vector *y)122 { 123 vector tmp;121 void Vector::ProjectOntoPlane(const Vector *y) 122 { 123 Vector tmp; 124 124 tmp.CopyVector(y); 125 125 tmp.Scale(Projection(y)); … … 131 131 * \return \f$\langle x, y \rangle\f$ 132 132 */ 133 double vector::Projection(const vector *y) const133 double Vector::Projection(const Vector *y) const 134 134 { 135 135 return (ScalarProduct(y)); … … 139 139 * \return \f$|x|\f$ 140 140 */ 141 double vector::Norm() const141 double Vector::Norm() const 142 142 { 143 143 double res = 0.; … … 149 149 /** Normalizes this vector. 150 150 */ 151 void vector::Normalize()151 void Vector::Normalize() 152 152 { 153 153 double res = 0.; … … 160 160 /** Zeros all components of this vector. 161 161 */ 162 void vector::Zero()162 void Vector::Zero() 163 163 { 164 164 for (int i=NDIM;i--;) … … 168 168 /** Zeros all components of this vector. 169 169 */ 170 void vector::One(double one)170 void Vector::One(double one) 171 171 { 172 172 for (int i=NDIM;i--;) … … 176 176 /** Initialises all components of this vector. 177 177 */ 178 void vector::Init(double x1, double x2, double x3)178 void Vector::Init(double x1, double x2, double x3) 179 179 { 180 180 x[0] = x1; … … 187 187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 188 188 */ 189 double vector::Angle(vector *y) const189 double Vector::Angle(Vector *y) const 190 190 { 191 191 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); … … 196 196 * \param alpha rotation angle in radian 197 197 */ 198 void vector::RotateVector(const vector *axis, const double alpha)199 { 200 vector a,y;198 void Vector::RotateVector(const Vector *axis, const double alpha) 199 { 200 Vector a,y; 201 201 // normalise this vector with respect to axis 202 202 a.CopyVector(this); … … 220 220 * \return lhs + a 221 221 */ 222 vector& operator+=(vector& a, const vector& b)222 Vector& operator+=(Vector& a, const Vector& b) 223 223 { 224 224 a.AddVector(&b); … … 230 230 * \return lhs.x[i] * m 231 231 */ 232 vector& operator*=(vector& a, const double m)232 Vector& operator*=(Vector& a, const double m) 233 233 { 234 234 a.Scale(m); … … 241 241 * \return a + b 242 242 */ 243 vector& operator+(const vector& a, const vector& b)244 { 245 vector *x = new vector;243 Vector& operator+(const Vector& a, const Vector& b) 244 { 245 Vector *x = new Vector; 246 246 x->CopyVector(&a); 247 247 x->AddVector(&b); … … 254 254 * \return a + b 255 255 */ 256 vector& operator*(const vector& a, const double m)257 { 258 vector *x = new vector;256 Vector& operator*(const Vector& a, const double m) 257 { 258 Vector *x = new Vector; 259 259 x->CopyVector(&a); 260 260 x->Scale(m); … … 266 266 * \param *out output stream 267 267 */ 268 bool vector::Output(ofstream *out) const268 bool Vector::Output(ofstream *out) const 269 269 { 270 270 if (out != NULL) { … … 281 281 }; 282 282 283 ofstream& operator<<(ofstream& ost, vector& m)283 ofstream& operator<<(ofstream& ost,Vector& m) 284 284 { 285 285 m.Output(&ost); … … 290 290 * \param *factor pointer to scaling factor 291 291 */ 292 void vector::Scale(double **factor)292 void Vector::Scale(double **factor) 293 293 { 294 294 for (int i=NDIM;i--;) … … 296 296 }; 297 297 298 void vector::Scale(double *factor)298 void Vector::Scale(double *factor) 299 299 { 300 300 for (int i=NDIM;i--;) … … 302 302 }; 303 303 304 void vector::Scale(double factor)304 void Vector::Scale(double factor) 305 305 { 306 306 for (int i=NDIM;i--;) … … 311 311 * \param trans[] translation vector. 312 312 */ 313 void vector::Translate(const vector *trans)313 void Vector::Translate(const Vector *trans) 314 314 { 315 315 for (int i=NDIM;i--;) … … 320 320 * \param *matrix NDIM_NDIM array 321 321 */ 322 void vector::MatrixMultiplication(double *M)323 { 324 vector C;322 void Vector::MatrixMultiplication(double *M) 323 { 324 Vector C; 325 325 // do the matrix multiplication 326 326 C.x[0] = M[0]*x[0]+M[3]*x[1]+M[6]*x[2]; … … 335 335 * \param *matrix NDIM_NDIM array 336 336 */ 337 void vector::InverseMatrixMultiplication(double *A)338 { 339 vector C;337 void Vector::InverseMatrixMultiplication(double *A) 338 { 339 Vector C; 340 340 double B[NDIM*NDIM]; 341 341 double detA = RDET3(A); … … 375 375 * \param *factors three-component vector with the factor for each given vector 376 376 */ 377 void vector::LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors)377 void Vector::LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors) 378 378 { 379 379 for(int i=NDIM;i--;) … … 384 384 * \param n[] normal vector of mirror plane. 385 385 */ 386 void vector::Mirror(const vector *n)386 void Vector::Mirror(const Vector *n) 387 387 { 388 388 double projection; … … 406 406 * \return true - success, vectors are linear independent, false - failure due to linear dependency 407 407 */ 408 bool vector::MakeNormalVector(const vector *y1, const vector *y2, const vector *y3)409 { 410 vector x1, x2;408 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2, const Vector *y3) 409 { 410 Vector x1, x2; 411 411 412 412 x1.CopyVector(y1); … … 442 442 * \return true - success, vectors are linear independent, false - failure due to linear dependency 443 443 */ 444 bool vector::MakeNormalVector(const vector *y1, const vector *y2)445 { 446 vector x1,x2;444 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2) 445 { 446 Vector x1,x2; 447 447 x1.CopyVector(y1); 448 448 x2.CopyVector(y2); … … 472 472 * \return true - success, false - vector is zero 473 473 */ 474 bool vector::MakeNormalVector(const vector *y1)474 bool Vector::MakeNormalVector(const Vector *y1) 475 475 { 476 476 bool result = false; 477 vector x1;477 Vector x1; 478 478 x1.CopyVector(y1); 479 479 x1.Scale(x1.Projection(this)); … … 491 491 * \return true - success, false - failure (null vector given) 492 492 */ 493 bool vector::GetOneNormalVector(const vector *GivenVector)493 bool Vector::GetOneNormalVector(const Vector *GivenVector) 494 494 { 495 495 int Components[NDIM]; // contains indices of non-zero components … … 537 537 * \return scaling parameter for this vector 538 538 */ 539 double vector::CutsPlaneAt(vector *A, vector *B, vector *C)539 double Vector::CutsPlaneAt(Vector *A, Vector *B, Vector *C) 540 540 { 541 541 // cout << Verbose(3) << "For comparison: "; … … 552 552 * \return true if success, false if failed due to linear dependency 553 553 */ 554 bool vector::LSQdistance(vector **vectors, int num)554 bool Vector::LSQdistance(Vector **vectors, int num) 555 555 { 556 556 int j; … … 634 634 * \param *y vector 635 635 */ 636 void vector::AddVector(const vector *y)636 void Vector::AddVector(const Vector *y) 637 637 { 638 638 for (int i=NDIM;i--;) … … 643 643 * \param *y vector 644 644 */ 645 void vector::SubtractVector(const vector *y)645 void Vector::SubtractVector(const Vector *y) 646 646 { 647 647 for (int i=NDIM;i--;) … … 652 652 * \param *y vector 653 653 */ 654 void vector::CopyVector(const vector *y)654 void Vector::CopyVector(const Vector *y) 655 655 { 656 656 for (int i=NDIM;i--;) … … 663 663 * \param check whether bounds shall be checked (true) or not (false) 664 664 */ 665 void vector::AskPosition(double *cell_size, bool check)665 void Vector::AskPosition(double *cell_size, bool check) 666 666 { 667 667 char coords[3] = {'x','y','z'}; … … 691 691 * \bug this is not yet working properly 692 692 */ 693 bool vector::SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c)693 bool Vector::SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c) 694 694 { 695 695 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.
