Changeset f75030 for molecuilder/src/vector.cpp
- Timestamp:
- May 23, 2008, 9:17:19 AM (17 years ago)
- Children:
- 6145aa7
- Parents:
- 6c96f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
r6c96f4 rf75030 25 25 { 26 26 double res = 0.; 27 for (int i= 0;i<NDIM;i++)27 for (int i=NDIM;i--;) 28 28 res += (x[i]-y->x[i])*(x[i]-y->x[i]); 29 29 return (res); … … 55 55 // create the translation vector 56 56 TranslationVector.Zero(); 57 for (int i= 0;i<NDIM;i++)57 for (int i=NDIM;i--;) 58 58 TranslationVector.x[i] = (double)N[i]; 59 59 TranslationVector.MatrixMultiplication(matrix); … … 84 84 TestVector.CopyVector(this); 85 85 TestVector.InverseMatrixMultiplication(matrix); 86 for(int i= 0;i<NDIM;i++) { // correct periodically86 for(int i=NDIM;i--;) { // correct periodically 87 87 if (TestVector.x[i] < 0) { // get every coefficient into the interval [0,1) 88 88 TestVector.x[i] += ceil(TestVector.x[i]); … … 106 106 { 107 107 double res = 0.; 108 for (int i= 0;i<NDIM;i++)108 for (int i=NDIM;i--;) 109 109 res += x[i]*y->x[i]; 110 110 return (res); … … 126 126 { 127 127 double res = 0.; 128 for (int i= 0;i<NDIM;i++)128 for (int i=NDIM;i--;) 129 129 res += this->x[i]*this->x[i]; 130 130 return (sqrt(res)); … … 136 136 { 137 137 double res = 0.; 138 for (int i= 0;i<NDIM;i++)138 for (int i=NDIM;i--;) 139 139 res += this->x[i]*this->x[i]; 140 140 res = 1./sqrt(res); … … 146 146 void vector::Zero() 147 147 { 148 for (int i= 0;i<NDIM;i++)148 for (int i=NDIM;i--;) 149 149 this->x[i] = 0.; 150 150 }; … … 259 259 void vector::Scale(double **factor) 260 260 { 261 for (int i= 0;i<NDIM;i++)261 for (int i=NDIM;i--;) 262 262 x[i] *= (*factor)[i]; 263 263 }; … … 265 265 void vector::Scale(double *factor) 266 266 { 267 for (int i= 0;i<NDIM;i++)267 for (int i=NDIM;i--;) 268 268 x[i] *= *factor; 269 269 }; … … 271 271 void vector::Scale(double factor) 272 272 { 273 for (int i= 0;i<NDIM;i++)273 for (int i=NDIM;i--;) 274 274 x[i] *= factor; 275 275 }; … … 280 280 void vector::Translate(const vector *trans) 281 281 { 282 for (int i= 0;i<NDIM;i++)282 for (int i=NDIM;i--;) 283 283 x[i] += trans->x[i]; 284 284 }; … … 295 295 C.x[2] = M[2]*x[0]+M[5]*x[1]+M[8]*x[2]; 296 296 // transfer the result into this 297 for (int i= 0;i<NDIM;i++)297 for (int i=NDIM;i--;) 298 298 x[i] = C.x[i]; 299 299 }; … … 327 327 C.x[2] = B[2]*x[0]+B[5]*x[1]+B[8]*x[2]; 328 328 // transfer the result into this 329 for (int i= 0;i<NDIM;i++)329 for (int i=NDIM;i--;) 330 330 x[i] = C.x[i]; 331 331 } else { … … 344 344 void vector::LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors) 345 345 { 346 for(int i= 0;i<NDIM;i++)346 for(int i=NDIM;i--;) 347 347 x[i] = factors[0]*x1->x[i] + factors[1]*x2->x[i] + factors[2]*x3->x[i]; 348 348 }; … … 359 359 Output((ofstream *)&cout); 360 360 cout << "\t"; 361 for (int i= 0;i<NDIM;i++)361 for (int i=NDIM;i--;) 362 362 x[i] -= 2.*projection*n->x[i]; 363 363 cout << "Projected vector: "; … … 446 446 x1.Scale(x1.Projection(this)); 447 447 SubtractVector(&x1); 448 for (int i= 0;i<NDIM;i++)448 for (int i=NDIM;i--;) 449 449 result = result || (fabs(x[i]) > MYEPSILON); 450 450 … … 468 468 vector->Output((ofstream *)&cout); 469 469 cout << endl; 470 for (j= 0;j<NDIM;j++)470 for (j=NDIM;j--;) 471 471 Components[j] = -1; 472 472 // find two components != 0 … … 537 537 par.num = num; 538 538 539 for (i= 0;i<NDIM;i++)539 for (i=NDIM;i--;) 540 540 gsl_vector_set(x, i, (vectors[0]->x[i] - vectors[1]->x[i])/2.); 541 541 … … 573 573 while (status == GSL_CONTINUE && iter < 100); 574 574 575 for (i= 0;i<(size_t)np;i++)575 for (i=(size_t)np;i--;) 576 576 this->x[i] = gsl_vector_get(s->x, i); 577 577 gsl_vector_free(x); … … 587 587 void vector::AddVector(const vector *y) 588 588 { 589 for (int i= 0;i<NDIM;i++)589 for (int i=NDIM;i--;) 590 590 this->x[i] += y->x[i]; 591 591 } … … 596 596 void vector::SubtractVector(const vector *y) 597 597 { 598 for (int i= 0;i<NDIM;i++)598 for (int i=NDIM;i--;) 599 599 this->x[i] -= y->x[i]; 600 600 } … … 605 605 void vector::CopyVector(const vector *y) 606 606 { 607 for (int i= 0;i<NDIM;i++)607 for (int i=NDIM;i--;) 608 608 this->x[i] = y->x[i]; 609 609 } … … 783 783 cout << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n"; 784 784 // apply sign matrix 785 for (j= 0;j<NDIM;j++)785 for (j=NDIM;j--;) 786 786 x[j] *= sign[j]; 787 787 // calculate angle and check … … 792 792 } 793 793 // unapply sign matrix (is its own inverse) 794 for (j= 0;j<NDIM;j++)794 for (j=NDIM;j--;) 795 795 x[j] *= sign[j]; 796 796 }
Note:
See TracChangeset
for help on using the changeset viewer.