Ignore:
Timestamp:
Apr 13, 2010, 1:22:42 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
e7ea64
Parents:
0f55b2
Message:

Prepared interface of Vector Class for transition to VectorComposites

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecule_geometry.cpp

    r0f55b2 r1f591b  
    3030
    3131  // go through all atoms
    32   ActOnAllVectors( &Vector::SubtractVector, Center);
     32  ActOnAllVectors( &Vector::SubtractVector, *Center);
    3333  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    3434
     
    8686//    Log() << Verbose(0) << endl;
    8787    min->Scale(-1.);
    88     max->AddVector(min);
     88    (*max) += (*min);
    8989    Translate(min);
    9090    Center.Zero();
     
    109109      ptr = ptr->next;
    110110      Num++;
    111       Center.AddVector(&ptr->x);
     111      Center += ptr->x;
    112112    }
    113113    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    133133      ptr = ptr->next;
    134134      Num += 1.;
    135       tmp.CopyVector(&ptr->x);
    136       a->AddVector(&tmp);
     135      tmp = ptr->x;
     136      (*a) += tmp;
    137137    }
    138138    a->Scale(1./Num); // divide through total mass (and sign for direction)
     
    158158      ptr = ptr->next;
    159159      Num += ptr->type->mass;
    160       tmp.CopyVector(&ptr->x);
    161       tmp.Scale(ptr->type->mass);  // scale by mass
    162       a->AddVector(&tmp);
     160      tmp = ptr->type->mass * ptr->x;
     161      (*a) += tmp;
    163162    }
    164163    a->Scale(-1./Num); // divide through total mass (and sign for direction)
     
    186185void molecule::CenterAtVector(Vector *newcenter)
    187186{
    188   Center.CopyVector(newcenter);
     187  Center = *newcenter;
    189188};
    190189
     
    215214    ptr = ptr->next;
    216215    for (int j=0;j<MDSteps;j++)
    217       ptr->Trajectory.R.at(j).Translate(trans);
    218     ptr->x.Translate(trans);
     216      ptr->Trajectory.R.at(j).Translate(*trans);
     217    ptr->x.Translate(*trans);
    219218  }
    220219};
     
    230229
    231230  // go through all atoms
    232   ActOnAllVectors( &Vector::SubtractVector, trans);
     231  ActOnAllVectors( &Vector::SubtractVector, *trans);
    233232  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    234233
     
    243242void molecule::Mirror(const Vector *n)
    244243{
    245   ActOnAllVectors( &Vector::Mirror, n );
     244  ActOnAllVectors( &Vector::Mirror, *n );
    246245};
    247246
     
    266265      if (Walker->type->Z != 1) {
    267266#endif
    268         Testvector.CopyVector(&Walker->x);
     267        Testvector = Walker->x;
    269268        Testvector.MatrixMultiplication(inversematrix);
    270269        Translationvector.Zero();
     
    283282            }
    284283        }
    285         Testvector.AddVector(&Translationvector);
     284        Testvector += Translationvector;
    286285        Testvector.MatrixMultiplication(matrix);
    287         Center.AddVector(&Testvector);
     286        Center += Testvector;
    288287        Log() << Verbose(1) << "vector is: " << Testvector << endl;
    289288#ifdef ADDHYDROGEN
     
    291290        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    292291          if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    293             Testvector.CopyVector(&(*Runner)->GetOtherAtom(Walker)->x);
     292            Testvector = (*Runner)->GetOtherAtom(Walker)->x;
    294293            Testvector.MatrixMultiplication(inversematrix);
    295             Testvector.AddVector(&Translationvector);
     294            Testvector += Translationvector;
    296295            Testvector.MatrixMultiplication(matrix);
    297             Center.AddVector(&Testvector);
     296            Center += Testvector;
    298297            Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
    299298          }
     
    329328  while (ptr->next != end) {
    330329    ptr = ptr->next;
    331     Vector x;
    332     x.CopyVector(&ptr->x);
     330    Vector x = ptr->x;
    333331    //x.SubtractVector(CenterOfGravity);
    334332    InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     
    381379    while (ptr->next != end) {
    382380      ptr = ptr->next;
    383       Vector x;
    384       x.CopyVector(&ptr->x);
     381      Vector x = ptr->x;
    385382      //x.SubtractVector(CenterOfGravity);
    386383      InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     
    492489    ptr = ptr->next;
    493490    if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    494       c.CopyVector(&ptr->x);  // copy vector to temporary one
    495       c.SubtractVector(&a);   // subtract offset vector
    496       t = c.ScalarProduct(&b);           // get direction parameter
    497       d.CopyVector(&b);       // and create vector
    498       d.Scale(&t);
    499       c.SubtractVector(&d);   // ... yielding distance vector
    500       res += d.ScalarProduct((const Vector *)&d);        // add squared distance
     491      c = ptr->x - a;
     492      t = c.ScalarProduct(b);           // get direction parameter
     493      d = t*b;       // and create vector
     494      c -= d;   // ... yielding distance vector
     495      res += d.ScalarProduct(d);        // add squared distance
    501496    }
    502497  }
Note: See TracChangeset for help on using the changeset viewer.