Changeset 0a4f7f for src


Ignore:
Timestamp:
Apr 7, 2010, 3:45:38 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, Candidate_v1.7.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
72e7fa
Parents:
f9352d
Message:

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
Location:
src
Files:
9 added
29 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    rf9352d r0a4f7f  
    2424#include "molecule.hpp"
    2525#include "periodentafel.hpp"
     26#include "vector_ops.hpp"
     27#include "Plane.hpp"
    2628
    2729#include "UIElements/UIFactory.hpp"
     
    7779      break;
    7880      case 'a': // absolute coordinates of atom
    79         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     81      {
    8082        first = World::getInstance().createAtom();
    81         first->x.AskPosition(mol->cell_size, false);
    82         first->type = periode->AskElement();  // give type
    83         mol->AddAtom(first);  // add to molecule
    84         break;
     83        Dialog *dialog = UIFactory::getInstance().makeDialog();
     84        dialog->queryVector("Enter absolute coordinates.",&first->x,mol->cell_size, false);
     85        dialog->queryElement("Choose element for this atom",&first->type);
     86        if(dialog->display()){
     87          mol->AddAtom(first);  // add to molecule
     88        }
     89        else{
     90          // dialog was canceled... destroy the atom that was used
     91          World::getInstance().destroyAtom(first);
     92        }
     93        delete dialog;
     94      }
     95      break;
    8596
    8697      case 'b': // relative coordinates of atom wrt to reference point
     
    8899        valid = true;
    89100        do {
     101          Dialog *dialog = UIFactory::getInstance().makeDialog();
    90102          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    91           Log() << Verbose(0) << "Enter reference coordinates." << endl;
    92           x.AskPosition(mol->cell_size, true);
    93           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    94           first->x.AskPosition(mol->cell_size, false);
    95           first->x.AddVector((const Vector *)&x);
    96           Log() << Verbose(0) << "\n";
    97         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     103          dialog->queryVector("Enter reference coordinates.",&x,mol->cell_size,true);
     104          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     105          first->x.AddVector(&x);
     106          dialog->display();
     107          delete dialog;
     108        } while (!(valid = mol->CheckBounds(&first->x)));
    98109        first->type = periode->AskElement();  // give type
    99110        mol->AddAtom(first);  // add to molecule
     
    101112
    102113      case 'c': // relative coordinates of atom wrt to already placed atom
     114      {
    103115        first = World::getInstance().createAtom();
    104116        valid = true;
     
    106118          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    107119          second = mol->AskAtom("Enter atom number: ");
    108           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    109           first->x.AskPosition(mol->cell_size, false);
     120          Dialog *dialog = UIFactory::getInstance().makeDialog();
     121          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     122          dialog->display();
    110123          for (int i=NDIM;i--;) {
    111             first->x.x[i] += second->x.x[i];
     124            first->x[i] += second->x[i];
    112125          }
    113126        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    114127        first->type = periode->AskElement();  // give type
    115128        mol->AddAtom(first);  // add to molecule
    116         break;
     129      }
     130      break;
    117131
    118132    case 'd': // two atoms, two angles and a distance
     
    157171          x.SubtractVector(&third->x);
    158172          x.Normalize();
    159           Log() << Verbose(0) << "x: ",
    160           x.Output();
    161           Log() << Verbose(0) << endl;
    162           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    163           Log() << Verbose(0) << "z: ",
    164           z.Output();
    165           Log() << Verbose(0) << endl;
    166           y.MakeNormalVector(&x,&z);
    167           Log() << Verbose(0) << "y: ",
    168           y.Output();
    169           Log() << Verbose(0) << endl;
     173          Log() << Verbose(0) << "x: " << x << endl;
     174          z = Plane(second->x,third->x,fourth->x).getNormal();
     175          Log() << Verbose(0) << "z: " << z << endl;
     176          y = Plane(x,z,0).getNormal();
     177          Log() << Verbose(0) << "y: " << y << endl;
    170178
    171179          // rotate vector around first angle
    172180          first->x.CopyVector(&x);
    173           first->x.RotateVector(&z,b - M_PI);
    174           Log() << Verbose(0) << "Rotated vector: ",
    175           first->x.Output();
    176           Log() << Verbose(0) << endl;
     181          first->x = RotateVector(first->x,z,b - M_PI);
     182          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    177183          // remove the projection onto the rotation plane of the second angle
    178184          n.CopyVector(&y);
    179185          n.Scale(first->x.ScalarProduct(&y));
    180           Log() << Verbose(0) << "N1: ",
    181           n.Output();
    182           Log() << Verbose(0) << endl;
     186          Log() << Verbose(0) << "N1: " << n << endl;
    183187          first->x.SubtractVector(&n);
    184           Log() << Verbose(0) << "Subtracted vector: ",
    185           first->x.Output();
    186           Log() << Verbose(0) << endl;
     188          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
    187189          n.CopyVector(&z);
    188190          n.Scale(first->x.ScalarProduct(&z));
    189           Log() << Verbose(0) << "N2: ",
    190           n.Output();
    191           Log() << Verbose(0) << endl;
     191          Log() << Verbose(0) << "N2: " << n << endl;
    192192          first->x.SubtractVector(&n);
    193           Log() << Verbose(0) << "2nd subtracted vector: ",
    194           first->x.Output();
    195           Log() << Verbose(0) << endl;
     193          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    196194
    197195          // rotate another vector around second angle
    198196          n.CopyVector(&y);
    199           n.RotateVector(&x,c - M_PI);
    200           Log() << Verbose(0) << "2nd Rotated vector: ",
    201           n.Output();
    202           Log() << Verbose(0) << endl;
     197          n = RotateVector(n,x,c - M_PI);
     198          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
    203199
    204200          // add the two linear independent vectors
     
    208204          first->x.AddVector(&second->x);
    209205
    210           Log() << Verbose(0) << "resulting coordinates: ";
    211           first->x.Output();
    212           Log() << Verbose(0) << endl;
     206          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
    213207        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    214208        first->type = periode->AskElement();  // give type
     
    233227        } while ((j != -1) && (i<128));
    234228        if (i >= 2) {
    235           first->x.LSQdistance((const Vector **)atoms, i);
    236 
    237           first->x.Output();
     229          LSQdistance(first->x,(const Vector **)atoms, i);
     230
     231          Log() << Verbose(0) << first->x;
    238232          first->type = periode->AskElement();  // give type
    239233          mol->AddAtom(first);  // add to molecule
     
    280274      for (int i=0;i<NDIM;i++) {
    281275        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    282         cin >> y.x[i];
     276        cin >> y[i];
    283277      }
    284278      mol->CenterEdge(&x);  // make every coordinate positive
     
    293287      for (int i=0;i<NDIM;i++) {
    294288        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    295         cin >> x.x[i];
     289        cin >> x[i];
    296290      }
    297291      // update Box of atoms by boundary
     
    330324      third = mol->AskAtom("Enter third atom: ");
    331325
    332       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     326      n = Plane(first->x,second->x,third->x).getNormal();
    333327      break;
    334328    case 'b': // normal vector of mirror plane
    335       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    336       n.AskPosition(mol->cell_size,0);
     329    {
     330      Dialog *dialog = UIFactory::getInstance().makeDialog();
     331      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     332      dialog->display();
     333      delete dialog;
    337334      n.Normalize();
    338       break;
     335    }
     336    break;
     337
    339338    case 'c': // three atoms defining mirror plane
    340339      first = mol->AskAtom("Enter first atom: ");
     
    356355      mol->GetAlignvector(&param);
    357356      for (int i=NDIM;i--;) {
    358         x.x[i] = gsl_vector_get(param.x,i);
    359         n.x[i] = gsl_vector_get(param.x,i+NDIM);
     357        x[i] = gsl_vector_get(param.x,i);
     358        n[i] = gsl_vector_get(param.x,i+NDIM);
    360359      }
    361360      gsl_vector_free(param.x);
    362       Log() << Verbose(0) << "Offset vector: ";
    363       x.Output();
    364       Log() << Verbose(0) << endl;
     361      Log() << Verbose(0) << "Offset vector: " << x << endl;
    365362      n.Normalize();
    366363      break;
    367364  };
    368   Log() << Verbose(0) << "Alignment vector: ";
    369   n.Output();
    370   Log() << Verbose(0) << endl;
     365  Log() << Verbose(0) << "Alignment vector: " << n << endl;
    371366  mol->Align(&n);
    372367};
     
    397392      third = mol->AskAtom("Enter third atom: ");
    398393
    399       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     394      n = Plane(first->x,second->x,third->x).getNormal();
    400395      break;
    401396    case 'b': // normal vector of mirror plane
    402       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    403       n.AskPosition(mol->cell_size,0);
     397    {
     398      Dialog *dialog = UIFactory::getInstance().makeDialog();
     399      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     400      dialog->display();
     401      delete dialog;
    404402      n.Normalize();
    405       break;
     403    }
     404    break;
     405
    406406    case 'c': // three atoms defining mirror plane
    407407      first = mol->AskAtom("Enter first atom: ");
     
    413413      break;
    414414  };
    415   Log() << Verbose(0) << "Normal vector: ";
    416   n.Output();
    417   Log() << Verbose(0) << endl;
     415  Log() << Verbose(0) << "Normal vector: " << n << endl;
    418416  mol->Mirror((const Vector *)&n);
    419417};
     
    471469        first = second;
    472470        second = first->next;
    473         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     471        if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474472          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475473          mol->RemoveAtom(first);
     
    541539      x.SubtractVector((const Vector *)&second->x);
    542540      tmp1 = x.Norm();
    543       Log() << Verbose(1) << "Distance vector is ";
    544       x.Output();
    545       Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     541      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
     542            << "Norm of distance is " << tmp1 << "." << endl;
    546543      break;
    547544
     
    676673        minBond = 0.;
    677674        for (int i=NDIM;i--;)
    678           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
     675          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
    679676        minBond = sqrt(minBond);
    680677        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     
    682679        cin >> bond;
    683680        for (int i=NDIM;i--;) {
    684           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
     681          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
    685682        }
    686683        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     
    778775      x.Zero();
    779776      y.Zero();
    780       y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     777      y[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    781778      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    782779        x.AddVector(&y); // per factor one cell width further
     
    893890        mol = *ListRunner;
    894891        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    895         Log() << Verbose(0) << "Enter translation vector." << endl;
    896         x.AskPosition(mol->cell_size,0);
     892        Dialog *dialog = UIFactory::getInstance().makeDialog();
     893        dialog->queryVector("Enter translation vector.",&x,mol->cell_size,false);
     894        dialog->display();
     895        delete dialog;
    897896        mol->Center.AddVector((const Vector *)&x);
    898897     }
  • src/Makefile.am

    rf9352d r0a4f7f  
     1# this includes source files that need to be present at multiple points
     2HELPERSOURCE =  Helpers/Assert.cpp
     3                       
    14ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp
    25ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp
    36
    4 LINALGSOURCE = gslmatrix.cpp gslvector.cpp linearsystemofequations.cpp
    5 LINALGHEADER = gslmatrix.hpp gslvector.hpp linearsystemofequations.hpp
     7LINALGSOURCE = ${HELPERSOURCE} \
     8               gslmatrix.cpp \
     9                           gslvector.cpp \
     10                           linearsystemofequations.cpp \
     11                           vector.cpp
     12                           
     13LINALGHEADER = gslmatrix.hpp \
     14                           gslvector.hpp \
     15                           linearsystemofequations.hpp \
     16                           vector.hpp
     17                           
    618
    719ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp
     
    7082
    7183
     84EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
     85                                  Exceptions/LinearDependenceException.cpp
     86                                 
     87EXCEPTIONHEADER = Exceptions/CustomException.hpp \
     88                                  Exceptions/LinearDependenceException.hpp
     89
    7290SOURCE = ${ANALYSISSOURCE} \
    7391                 ${ATOMSOURCE} \
     
    7593                 ${UISOURCE} \
    7694                 ${DESCRIPTORSOURCE} \
     95                 ${HELPERSOURCE} \
    7796                 ${LEGACYSOURCE} \
     97                 ${EXCEPTIONSOURCE} \
    7898                 bond.cpp \
    7999                 bondgraph.cpp \
     
    85105                 graph.cpp \
    86106                 helpers.cpp \
    87                  Helpers/Assert.cpp \
    88107                 info.cpp \
    89108                 leastsquaremin.cpp \
     
    102121                 parser.cpp \
    103122                 periodentafel.cpp \
     123                 Plane.cpp \
    104124                 tesselation.cpp \
    105125                 tesselationhelpers.cpp \
    106                  vector.cpp \
    107126                 verbose.cpp \
     127                 vector_ops.cpp \
    108128                 World.cpp
    109 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} ${UIHEADER} ${DESCRIPTORHEADER} ${LEGACYHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp World.hpp
     129                 
     130HEADER = ${ANALYSISHEADER} \
     131         ${ATOMHEADER} \
     132         ${PATTERNHEADER} \
     133         ${UIHEADER} \
     134         ${DESCRIPTORHEADER} \
     135         ${LEGACYHEADER} \
     136         ${EXCEPTIONHEADER} \
     137         bond.hpp \
     138         bondgraph.hpp \
     139         boundary.hpp \
     140         config.hpp \
     141         defs.hpp \
     142         element.hpp \
     143         ellipsoid.hpp \
     144         errorlogger.hpp \
     145         graph.hpp \
     146         info.hpp \
     147         leastsquaremin.hpp \
     148         linkedcell.hpp \
     149         lists.hpp \
     150         log.hpp \
     151         logger.hpp \
     152         memoryallocator.hpp \
     153         memoryusageobserver.hpp \
     154         molecule.hpp \
     155         molecule_template.hpp \
     156         parser.hpp \
     157         periodentafel.hpp \
     158         Plane.hpp \
     159         stackclass.hpp \
     160         tesselation.hpp \
     161         tesselationhelpers.hpp \
     162         verbose.hpp \
     163         vector_ops.hpp \
     164         World.hpp
    110165
    111166BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
  • src/UIElements/TextDialog.cpp

    rf9352d r0a4f7f  
    119119
    120120bool TextDialog::VectorTextQuery::handle() {
    121  Log() << Verbose(0) << getTitle();
    122  tmp->AskPosition(cellSize,check);
    123  return true;
     121  Log() << Verbose(0) << getTitle();
     122
     123  char coords[3] = {'x','y','z'};
     124  int j = -1;
     125  for (int i=0;i<3;i++) {
     126    j += i+1;
     127    do {
     128      Log() << Verbose(0) << coords[i] << "[0.." << cellSize[j] << "]: ";
     129      cin >> (*tmp)[i];
     130    } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= cellSize[j])) && (check));
     131  }
     132  return true;
    124133}
    125134
  • src/analysis_correlation.cpp

    rf9352d r0a4f7f  
    400400    *file << runner->first;
    401401    for (int i=0;i<NDIM;i++)
    402       *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);
     402      *file << "\t" << (runner->second.first->node->at(i) - runner->second.second->at(i));
    403403    *file << endl;
    404404  }
  • src/atom.cpp

    rf9352d r0a4f7f  
    130130  if (out != NULL) {
    131131    *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
    132     *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
     132    *out << x[0] << "\t" << x[1] << "\t" << x[2];
    133133    *out << "\t" << FixedIon;
    134134    if (v.Norm() > MYEPSILON)
    135       *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
     135      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
    136136    if (comment != NULL)
    137137      *out << " # " << comment << endl;
     
    155155  if (out != NULL) {
    156156    *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    157     *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
     157    *out << x[0] << "\t" << x[1] << "\t" << x[2];
    158158    *out << "\t" << FixedIon;
    159159    if (v.Norm() > MYEPSILON)
    160       *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
     160      *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
    161161    if (comment != NULL)
    162162      *out << " # " << comment << endl;
     
    175175{
    176176  if (out != NULL) {
    177     *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl;
     177    *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
    178178    return true;
    179179  } else
     
    193193  if (out != NULL) {
    194194    *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    195     *out << Trajectory.R.at(step).x[0] << "\t" << Trajectory.R.at(step).x[1] << "\t" << Trajectory.R.at(step).x[2];
     195    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    196196    *out << "\t" << FixedIon;
    197197    if (Trajectory.U.at(step).Norm() > MYEPSILON)
    198       *out << "\t" << scientific << setprecision(6) << Trajectory.U.at(step).x[0] << "\t" << Trajectory.U.at(step).x[1] << "\t" << Trajectory.U.at(step).x[2] << "\t";
     198      *out << "\t" << scientific << setprecision(6) << Trajectory.U.at(step)[0] << "\t" << Trajectory.U.at(step)[1] << "\t" << Trajectory.U.at(step)[2] << "\t";
    199199    if (Trajectory.F.at(step).Norm() > MYEPSILON)
    200       *out << "\t" << scientific << setprecision(6) << Trajectory.F.at(step).x[0] << "\t" << Trajectory.F.at(step).x[1] << "\t" << Trajectory.F.at(step).x[2] << "\t";
     200      *out << "\t" << scientific << setprecision(6) << Trajectory.F.at(step)[0] << "\t" << Trajectory.F.at(step)[1] << "\t" << Trajectory.F.at(step)[2] << "\t";
    201201    *out << "\t# Number in molecule " << nr << endl;
    202202    return true;
     
    214214  if (out != NULL) {
    215215    *out << type->symbol << "\t";
    216     *out << Trajectory.R.at(step).x[0] << "\t";
    217     *out << Trajectory.R.at(step).x[1] << "\t";
    218     *out << Trajectory.R.at(step).x[2] << endl;
     216    *out << Trajectory.R.at(step)[0] << "\t";
     217    *out << Trajectory.R.at(step)[1] << "\t";
     218    *out << Trajectory.R.at(step)[2] << endl;
    219219    return true;
    220220  } else
     
    229229void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
    230230{
    231   *out << "\t\t" << type->symbol << " [ " << x.x[0]-center->x[0] << "\t" << x.x[1]-center->x[1] << "\t" << x.x[2]-center->x[2] << " ]" << endl;
     231  *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
    232232  if (AtomNo != NULL)
    233233    *AtomNo++;
  • src/atom_trajectoryparticle.cpp

    rf9352d r0a4f7f  
    3434{
    3535  for (int i=NDIM;i--;)
    36     *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i];
     36    *temperature += type->mass * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];
    3737};
    3838
     
    6060{
    6161  for(int d=0;d<NDIM;d++) {
    62     Trajectory.U.at(Step).x[d] -= CoGVelocity->x[d];
    63     *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step).x[d] * Trajectory.U.at(Step).x[d];
     62    Trajectory.U.at(Step)[d] -= CoGVelocity->at(d);
     63    *ActualTemp += 0.5 * type->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];
    6464  }
    6565};
     
    8989
    9090  for (int n=NDIM;n--;) {
    91     Trajectory.R.at(dest).x[n] = Trajectory.R.at(src).x[n];
    92     Trajectory.U.at(dest).x[n] = Trajectory.U.at(src).x[n];
    93     Trajectory.F.at(dest).x[n] = Trajectory.F.at(src).x[n];
     91    Trajectory.R.at(dest)[n] = Trajectory.R.at(src)[n];
     92    Trajectory.U.at(dest)[n] = Trajectory.U.at(src)[n];
     93    Trajectory.F.at(dest)[n] = Trajectory.F.at(src)[n];
    9494  }
    9595};
     
    105105  //a = configuration.Deltat*0.5/walker->type->mass;        // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a
    106106  for (int d=0; d<NDIM; d++) {
    107     Trajectory.F.at(NextStep).x[d] = -Force->Matrix[0][nr][d+5]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
    108     Trajectory.R.at(NextStep).x[d] = Trajectory.R.at(NextStep-1).x[d];
    109     Trajectory.R.at(NextStep).x[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1).x[d]);     // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
    110     Trajectory.R.at(NextStep).x[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep).x[d]/type->mass);     // F = m * a and s =
     107    Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+5]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
     108    Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d];
     109    Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]);     // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
     110    Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/type->mass);     // F = m * a and s =
    111111  }
    112112  // Update U
    113113  for (int d=0; d<NDIM; d++) {
    114     Trajectory.U.at(NextStep).x[d] = Trajectory.U.at(NextStep-1).x[d];
    115     Trajectory.U.at(NextStep).x[d] += configuration->Deltat * (Trajectory.F.at(NextStep).x[d]+Trajectory.F.at(NextStep-1).x[d]/type->mass); // v = F/m * t
     114    Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d];
     115    Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/type->mass); // v = F/m * t
    116116  }
    117117  // Update R (and F)
     
    134134  *TotalMass += type->mass;  // sum up total mass
    135135  for(int d=0;d<NDIM;d++) {
    136     TotalVelocity->x[d] += Trajectory.U.at(Step).x[d]*type->mass;
     136    TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*type->mass;
    137137  }
    138138};
     
    145145void TrajectoryParticle::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
    146146{
    147   double *U = Trajectory.U.at(Step).x;
     147  Vector &U = Trajectory.U.at(Step);
    148148  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    149149    for (int d=0; d<NDIM; d++) {
     
    160160void TrajectoryParticle::Thermostat_Gaussian_init(int Step, double *G, double *E)
    161161{
    162   double *U = Trajectory.U.at(Step).x;
    163   double *F = Trajectory.F.at(Step).x;
     162  Vector &U = Trajectory.U.at(Step);
     163  Vector &F = Trajectory.F.at(Step);
    164164  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    165165    for (int d=0; d<NDIM; d++) {
     
    177177void TrajectoryParticle::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
    178178{
    179   double *U = Trajectory.U.at(Step).x;
     179  Vector &U = Trajectory.U.at(Step);
    180180  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    181181    for (int d=0; d<NDIM; d++) {
     
    194194{
    195195  double sigma  = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
    196   double *U = Trajectory.U.at(Step).x;
     196  Vector &U = Trajectory.U.at(Step);
    197197  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    198198    // throw a dice to determine whether it gets hit by a heat bath particle
     
    218218void TrajectoryParticle::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
    219219{
    220   double *U = Trajectory.U.at(Step).x;
     220  Vector &U = Trajectory.U.at(Step);
    221221  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    222222    for (int d=0; d<NDIM; d++) {
     
    233233void TrajectoryParticle::Thermostat_NoseHoover_init(int Step, double *delta_alpha)
    234234{
    235   double *U = Trajectory.U.at(Step).x;
     235  Vector &U = Trajectory.U.at(Step);
    236236  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    237237    for (int d=0; d<NDIM; d++) {
     
    248248void TrajectoryParticle::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)
    249249{
    250   double *U = Trajectory.U.at(Step).x;
     250  Vector &U = Trajectory.U.at(Step);
    251251  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    252252    for (int d=0; d<NDIM; d++) {
  • src/boundary.cpp

    rf9352d r0a4f7f  
    1818#include "tesselation.hpp"
    1919#include "tesselationhelpers.hpp"
     20#include "Plane.hpp"
    2021
    2122#include<gsl/gsl_poly.h>
     
    8081              DistanceVector.SubtractVector(&Neighbour->second.second->x);
    8182              do { // seek for neighbour pair where it flips
    82                   OldComponent = DistanceVector.x[Othercomponent];
     83                  OldComponent = DistanceVector[Othercomponent];
    8384                  Neighbour++;
    8485                  if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
     
    8889                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
    8990                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
    90                   OldComponent) - DistanceVector.x[Othercomponent] / fabs(
    91                   DistanceVector.x[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
     91                  OldComponent) - DistanceVector[Othercomponent] / fabs(
     92                  DistanceVector[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
    9293              if (runner != Neighbour) {
    9394                  OtherNeighbour = Neighbour;
     
    102103                  //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
    103104                  // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour
    104                   w1 = fabs(OtherVector.x[Othercomponent]);
    105                   w2 = fabs(DistanceVector.x[Othercomponent]);
    106                   tmp = fabs((w1 * DistanceVector.x[component] + w2
    107                       * OtherVector.x[component]) / (w1 + w2));
     105                  w1 = fabs(OtherVector[Othercomponent]);
     106                  w2 = fabs(DistanceVector[Othercomponent]);
     107                  tmp = fabs((w1 * DistanceVector[component] + w2
     108                      * OtherVector[component]) / (w1 + w2));
    108109                  // mark if it has greater diameter
    109110                  //Log() << Verbose(1) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
     
    159160    AngleReferenceVector.Zero();
    160161    AngleReferenceNormalVector.Zero();
    161     AxisVector.x[axis] = 1.;
    162     AngleReferenceVector.x[(axis + 1) % NDIM] = 1.;
    163     AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
     162    AxisVector[axis] = 1.;
     163    AngleReferenceVector[(axis + 1) % NDIM] = 1.;
     164    AngleReferenceNormalVector[(axis + 2) % NDIM] = 1.;
    164165
    165166    Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     
    636637      const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(runner->second->endpoints[1]->node->node));
    637638      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
    638       x.MakeNormalVector(runner->second->endpoints[0]->node->node, runner->second->endpoints[1]->node->node, runner->second->endpoints[2]->node->node);
     639      x = Plane(*(runner->second->endpoints[0]->node->node),
     640                *(runner->second->endpoints[1]->node->node),
     641                *(runner->second->endpoints[2]->node->node)).getNormal();
    639642      x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(&x));
    640643      const double h = x.Norm(); // distance of CoG to triangle
     
    751754    Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;
    752755    for (int i = 0; i < NDIM; i++)
    753       BoxLengths.x[i] = GreatestDiameter[i];
     756      BoxLengths[i] = GreatestDiameter[i];
    754757    mol->CenterEdge(&BoxLengths);
    755758  } else {
    756     BoxLengths.x[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
    757     BoxLengths.x[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
    758     BoxLengths.x[2] = minimumvolume - cellvolume;
     759    BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
     760    BoxLengths[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
     761    BoxLengths[2] = minimumvolume - cellvolume;
    759762    double x0 = 0.;
    760763    double x1 = 0.;
    761764    double x2 = 0.;
    762     if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
     765    if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    763766      Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
    764767    else {
     
    769772    cellvolume = 1.;
    770773    for (int i = 0; i < NDIM; i++) {
    771       BoxLengths.x[i] = repetition[i] * (x0 + GreatestDiameter[i]);
    772       cellvolume *= BoxLengths.x[i];
     774      BoxLengths[i] = repetition[i] * (x0 + GreatestDiameter[i]);
     775      cellvolume *= BoxLengths[i];
    773776    }
    774777
     
    780783  // update Box of atoms by boundary
    781784  mol->SetBoxDimension(&BoxLengths);
    782   Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     785  Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
    783786};
    784787
     
    839842  FillerDistance.InverseMatrixMultiplication(M);
    840843  for(int i=0;i<NDIM;i++)
    841     N[i] = (int) ceil(1./FillerDistance.x[i]);
     844    N[i] = static_cast<int>(ceil(1./FillerDistance[i]));
    842845  Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
    843846
     
    880883          // create molecule random translation vector ...
    881884          for (int i=0;i<NDIM;i++)
    882             FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     885            FillerTranslations[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    883886          Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
    884887
     
    892895            // create atomic random translation vector ...
    893896            for (int i=0;i<NDIM;i++)
    894               AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     897              AtomTranslations[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    895898
    896899            // ... and rotation matrix
  • src/builder.cpp

    rf9352d r0a4f7f  
    14871487                  Log() << Verbose(2) << "found element " << first->type->name << endl;
    14881488                for (int i=NDIM;i--;)
    1489                   first->x.x[i] = atof(argv[argptr+1+i]);
     1489                  first->x[i] = atof(argv[argptr+1+i]);
    14901490                if (first->type != NULL) {
    14911491                  mol->AddAtom(first);  // add to molecule
     
    18371837                Log() << Verbose(1) << "Translating all ions by given vector." << endl;
    18381838                for (int i=NDIM;i--;)
    1839                   x.x[i] = atof(argv[argptr+i]);
     1839                  x[i] = atof(argv[argptr+i]);
    18401840                mol->Translate((const Vector *)&x);
    18411841                argptr+=3;
     
    18531853                Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl;
    18541854                for (int i=NDIM;i--;)
    1855                   x.x[i] = atof(argv[argptr+i]);
     1855                  x[i] = atof(argv[argptr+i]);
    18561856                mol->TranslatePeriodically((const Vector *)&x);
    18571857                argptr+=3;
     
    18751875                for (int i=0;i<NDIM;i++) {
    18761876                  j += i+1;
    1877                   x.x[i] = atof(argv[NDIM+i]);
     1877                  x[i] = atof(argv[NDIM+i]);
    18781878                  mol->cell_size[j]*=factor[i];
    18791879                }
     
    19361936                for (int i=0;i<NDIM;i++) {
    19371937                  j += i+1;
    1938                   x.x[i] = atof(argv[argptr+i]);
    1939                   mol->cell_size[j] += x.x[i]*2.;
     1938                  x[i] = atof(argv[argptr+i]);
     1939                  mol->cell_size[j] += x[i]*2.;
    19401940                }
    19411941                mol->Translate((const Vector *)&x);
     
    20942094                    x.Zero();
    20952095                    y.Zero();
    2096                     y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     2096                    y[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    20972097                    for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    20982098                      x.AddVector(&y); // per factor one cell width further
  • src/config.cpp

    rf9352d r0a4f7f  
    740740              neues = AtomList[i][j];
    741741            status = (status &&
    742                     ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) &&
    743                     ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) &&
    744                     ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x.x[2], 1, (repetition == 0) ? critical : optional) &&
     742                    ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], 1, (repetition == 0) ? critical : optional) &&
     743                    ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], 1, (repetition == 0) ? critical : optional) &&
     744                    ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], 1, (repetition == 0) ? critical : optional) &&
    745745                    ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
    746746            if (!status) break;
     
    756756            // put into trajectories list
    757757            for (int d=0;d<NDIM;d++)
    758               neues->Trajectory.R.at(repetition).x[d] = neues->x.x[d];
     758              neues->Trajectory.R.at(repetition)[d] = neues->x[d];
    759759
    760760            // parse velocities if present
    761             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional))
    762               neues->v.x[0] = 0.;
    763             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v.x[1], 1,optional))
    764               neues->v.x[1] = 0.;
    765             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v.x[2], 1,optional))
    766               neues->v.x[2] = 0.;
     761            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], 1,optional))
     762              neues->v[0] = 0.;
     763            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], 1,optional))
     764              neues->v[1] = 0.;
     765            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], 1,optional))
     766              neues->v[2] = 0.;
    767767            for (int d=0;d<NDIM;d++)
    768               neues->Trajectory.U.at(repetition).x[d] = neues->v.x[d];
     768              neues->Trajectory.U.at(repetition)[d] = neues->v[d];
    769769
    770770            // parse forces if present
     
    776776              value[2] = 0.;
    777777            for (int d=0;d<NDIM;d++)
    778               neues->Trajectory.F.at(repetition).x[d] = value[d];
     778              neues->Trajectory.F.at(repetition)[d] = value[d];
    779779
    780780  //            Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": (";
     
    819819            neues = AtomList[i][j];
    820820          // then parse for each atom the coordinates as often as present
    821           ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical);
    822           ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical);
    823           ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition,critical);
     821          ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], repetition,critical);
     822          ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], repetition,critical);
     823          ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], repetition,critical);
    824824          ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical);
    825           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional))
    826             neues->v.x[0] = 0.;
    827           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional))
    828             neues->v.x[1] = 0.;
    829           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional))
    830             neues->v.x[2] = 0.;
     825          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], repetition,optional))
     826            neues->v[0] = 0.;
     827          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], repetition,optional))
     828            neues->v[1] = 0.;
     829          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], repetition,optional))
     830            neues->v[2] = 0.;
    831831          // here we don't care if forces are present (last in trajectories is always equal to current position)
    832832          neues->type = elementhash[i]; // find element type
     
    12891289        istringstream input2(zeile);
    12901290        atom *neues = World::getInstance().createAtom();
    1291         input2 >> neues->x.x[0]; // x
    1292         input2 >> neues->x.x[1]; // y
    1293         input2 >> neues->x.x[2]; // z
     1291        input2 >> neues->x[0]; // x
     1292        input2 >> neues->x[1]; // y
     1293        input2 >> neues->x[2]; // z
    12941294        input2 >> l;
    12951295        neues->type = elementhash[No]; // find element type
     
    15701570             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15711571             MolNo,         /* residue sequence number */
    1572              Walker->node->x[0],                 /* position X in Angstroem */
    1573              Walker->node->x[1],                 /* position Y in Angstroem */
    1574              Walker->node->x[2],                 /* position Z in Angstroem */
     1572             Walker->node->at(0),                 /* position X in Angstroem */
     1573             Walker->node->at(1),                 /* position Y in Angstroem */
     1574             Walker->node->at(2),                 /* position Z in Angstroem */
    15751575             (double)Walker->type->Valence,         /* occupancy */
    15761576             (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     
    16241624           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16251625           0,         /* residue sequence number */
    1626            Walker->node->x[0],                 /* position X in Angstroem */
    1627            Walker->node->x[1],                 /* position Y in Angstroem */
    1628            Walker->node->x[2],                 /* position Z in Angstroem */
     1626           Walker->node->at(0),                 /* position X in Angstroem */
     1627           Walker->node->at(1),                 /* position Y in Angstroem */
     1628           Walker->node->at(2),                 /* position Z in Angstroem */
    16291629           (double)Walker->type->Valence,         /* occupancy */
    16301630           (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     
    16771677    *output << mol->name << "\t";
    16781678    *output << 0 << "\t";
    1679     *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    1680     *output << (double)Walker->type->Valence << "\t";
     1679    *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
     1680    *output << static_cast<double>(Walker->type->Valence) << "\t";
    16811681    *output << Walker->type->symbol << "\t";
    16821682    for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
     
    17521752        *output << (*MolWalker)->name << "\t";
    17531753        *output << MolCounter << "\t";
    1754         *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
     1754        *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    17551755        *output << (double)Walker->type->Valence << "\t";
    17561756        *output << Walker->type->symbol << "\t";
  • src/ellipsoid.cpp

    rf9352d r0a4f7f  
    116116  // put parameters into suitable ellipsoid form
    117117  for (int i=0;i<3;i++) {
    118     Center.x[i] = gsl_vector_get(x, i+0);
     118    Center[i] = gsl_vector_get(x, i+0);
    119119    EllipsoidLength[i] = gsl_vector_get(x, i+3);
    120120    EllipsoidAngle[i] = gsl_vector_get(x, i+6);
     
    160160    x = gsl_vector_alloc (9);
    161161    for (int i=0;i<3;i++) {
    162       gsl_vector_set (x, i+0, EllipsoidCenter->x[i]);
     162      gsl_vector_set (x, i+0, EllipsoidCenter->at(i));
    163163      gsl_vector_set (x, i+3, EllipsoidLength[i]);
    164164      gsl_vector_set (x, i+6, EllipsoidAngle[i]);
     
    195195      if (status == GSL_SUCCESS) {
    196196        for (int i=0;i<3;i++) {
    197           EllipsoidCenter->x[i] = gsl_vector_get (s->x,i+0);
     197          EllipsoidCenter->at(i) = gsl_vector_get (s->x,i+0);
    198198          EllipsoidLength[i] = gsl_vector_get (s->x, i+3);
    199199          EllipsoidAngle[i] = gsl_vector_get (s->x, i+6);
     
    427427      output << number << "\t";
    428428      for (int i=0;i<3;i++)
    429         output << setprecision(9) << EllipsoidCenter.x[i] << "\t";
     429        output << setprecision(9) << EllipsoidCenter[i] << "\t";
    430430      for (int i=0;i<3;i++)
    431431        output << setprecision(9) << EllipsoidLength[i] << "\t";
  • src/gslmatrix.cpp

    rf9352d r0a4f7f  
    1010#include "gslmatrix.hpp"
    1111#include "helpers.hpp"
     12#include "Helpers/fast_functions.hpp"
    1213
    1314#include <cassert>
  • src/helpers.cpp

    rf9352d r0a4f7f  
    66
    77#include "helpers.hpp"
     8#include "Helpers/fast_functions.hpp"
    89#include "log.hpp"
    910#include "memoryusageobserver.hpp"
     
    4950  while (*b < lower_bound)
    5051    *b += step;
    51 };
    52 
    53 /** Returns the power of \a n with respect to \a base.
    54  * \param base basis
    55  * \param n power
    56  * \return \f$base^n\f$
    57  */
    58 int pot(int base, int n)
    59 {
    60   int res = 1;
    61   int j;
    62   for (j=n;j--;)
    63     res *= base;
    64   return res;
    6552};
    6653
     
    175162};
    176163
    177 /** hard-coded determinant of a 3x3 matrix.
    178  * \param a[9] matrix
    179  * \return \f$det(a)\f$
    180  */
    181 double RDET3(const double a[NDIM*NDIM])
    182 {
    183   return ((a)[0]*(a)[4]*(a)[8] + (a)[3]*(a)[7]*(a)[2] + (a)[6]*(a)[1]*(a)[5] - (a)[2]*(a)[4]*(a)[6] - (a)[5]*(a)[7]*(a)[0] - (a)[8]*(a)[1]*(a)[3]);
    184 };
    185 
    186 /** hard-coded determinant of a 2x2 matrix.
    187  * \param a[4] matrix
    188  * \return \f$det(a)\f$
    189  */
    190 double RDET2(const double a[4])
    191 {
    192   return ((a[0])*(a[3])-(a[1])*(a[2]));
    193 };
    194 
    195 /** hard-coded determinant of a 2x2 matrix.
    196  * \param a0 (0,0) entry of matrix
    197  * \param a1 (0,1) entry of matrix
    198  * \param a2 (1,0) entry of matrix
    199  * \param a3 (1,1) entry of matrix
    200  * \return \f$det(a)\f$
    201  */
    202 double RDET2(const double a0, const double a1, const double a2, const double a3)
    203 {
    204   return ((a0)*(a3)-(a1)*(a2));
    205 };
     164
    206165
    207166/** Comparison function for GSL heapsort on distances in two molecules.
  • src/helpers.hpp

    rf9352d r0a4f7f  
    2424/********************************************** definitions *********************************/
    2525
    26 // some algebraic matrix stuff
    27 double RDET3(const double a[NDIM*NDIM]);
    28 double RDET2(const double a[4]);
    29 double RDET2(const double a0, const double a1, const double a2, const double a3);
    30 
    3126/********************************************** helpful functions *********************************/
    3227
     
    5348bool check_bounds(double *x, double *cell_size);
    5449void bound(double *b, double lower_bound, double upper_bound);
    55 int pot(int base, int n);
    5650int CountLinesinFile(ifstream &InputFile);
    5751char *FixedDigitNumber(const int FragmentNumber, const int digits);
     
    6458/********************************************** helpful template functions *********************************/
    6559
    66 /** Flips two values.
    67  * \param x first value
    68  * \param y second value
    69  */
    70 template <typename T> void flip(T &x, T &y)
    71 {
    72   T tmp;
    73   tmp = x;
    74   x = y;
    75   y = tmp;
    76 };
    7760
    7861/** returns greater of the two values.
  • src/leastsquaremin.cpp

    rf9352d r0a4f7f  
    2525  for (int i=num;i--;) {
    2626    for(int j=NDIM;j--;)
    27       sum += (gsl_vector_get(x,j) - (vectors[i])->x[j])*(gsl_vector_get(x,j) - (vectors[i])->x[j]);
     27      sum += (gsl_vector_get(x,j) - (vectors[i])->at(j))*(gsl_vector_get(x,j) - (vectors[i])->at(j));
    2828  }
    2929
  • src/linearsystemofequations.cpp

    rf9352d r0a4f7f  
    5454{
    5555  assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!");
    56   b->SetFromDoubleArray(x->x);
     56  b->SetFromDoubleArray(x->get());
    5757};
    5858
     
    100100  // copy solution
    101101  for (size_t i=0;i<x->dimension;i++)
    102     v.x[i] = x->Get(i);
     102    v[i] = x->Get(i);
    103103  return status;
    104104};
  • src/linkedcell.cpp

    rf9352d r0a4f7f  
    5454  Walker = set->GetPoint();
    5555  for (int i=0;i<NDIM;i++) {
    56     max.x[i] = Walker->node->x[i];
    57     min.x[i] = Walker->node->x[i];
     56    max[i] = Walker->node->at(i);
     57    min[i] = Walker->node->at(i);
    5858  }
    5959  set->GoToFirst();
     
    6161    Walker = set->GetPoint();
    6262    for (int i=0;i<NDIM;i++) {
    63       if (max.x[i] < Walker->node->x[i])
    64         max.x[i] = Walker->node->x[i];
    65       if (min.x[i] > Walker->node->x[i])
    66         min.x[i] = Walker->node->x[i];
     63      if (max[i] < Walker->node->at(i))
     64        max[i] = Walker->node->at(i);
     65      if (min[i] > Walker->node->at(i))
     66        min[i] = Walker->node->at(i);
    6767    }
    6868    set->GoToNext();
     
    7272  // 2. find then number of cells per axis
    7373  for (int i=0;i<NDIM;i++) {
    74     N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
     74    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
    7575  }
    7676  Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
     
    9494    Walker = set->GetPoint();
    9595    for (int i=0;i<NDIM;i++) {
    96       n[i] = (int)floor((Walker->node->x[i] - min.x[i])/RADIUS);
     96      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
    9797    }
    9898    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
     
    128128  LinkedNodes::iterator Runner = set->begin();
    129129  for (int i=0;i<NDIM;i++) {
    130     max.x[i] = (*Runner)->node->x[i];
    131     min.x[i] = (*Runner)->node->x[i];
     130    max[i] = (*Runner)->node->at(i);
     131    min[i] = (*Runner)->node->at(i);
    132132  }
    133133  for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
    134134    Walker = *Runner;
    135135    for (int i=0;i<NDIM;i++) {
    136       if (max.x[i] < Walker->node->x[i])
    137         max.x[i] = Walker->node->x[i];
    138       if (min.x[i] > Walker->node->x[i])
    139         min.x[i] = Walker->node->x[i];
     136      if (max[i] < Walker->node->at(i))
     137        max[i] = Walker->node->at(i);
     138      if (min[i] > Walker->node->at(i))
     139        min[i] = Walker->node->at(i);
    140140    }
    141141  }
     
    144144  // 2. find then number of cells per axis
    145145  for (int i=0;i<NDIM;i++) {
    146     N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
     146    N[i] = static_cast<int>(floor((max[i] - min[i])/RADIUS)+1);
    147147  }
    148148  Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
     
    165165    Walker = *Runner;
    166166    for (int i=0;i<NDIM;i++) {
    167       n[i] = (int)floor((Walker->node->x[i] - min.x[i])/RADIUS);
     167      n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
    168168    }
    169169    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
     
    252252  bool status = false;
    253253  for (int i=0;i<NDIM;i++) {
    254     n[i] = (int)floor((Walker->node->x[i] - min.x[i])/RADIUS);
     254    n[i] = static_cast<int>(floor((Walker->node->at(i) - min[i])/RADIUS));
    255255  }
    256256  index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
     
    293293  bool status = true;
    294294  for (int i=0;i<NDIM;i++) {
    295     n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS);
    296     if (max.x[i] < x->x[i])
     295    n[i] = static_cast<int>(floor((x->at(i) - min[i])/RADIUS));
     296    if (max[i] < x->at(i))
    297297      status = false;
    298     if (min.x[i] > x->x[i])
     298    if (min[i] > x->at(i))
    299299      status = false;
    300300  }
  • src/molecule.cpp

    rf9352d r0a4f7f  
    2525#include "tesselation.hpp"
    2626#include "vector.hpp"
     27#include "Plane.hpp"
     28#include "Exceptions/LinearDependenceException.hpp"
    2729
    2830/************************************* Functions for class molecule *********************************/
     
    231233    Orthovector1.Zero();
    232234    for (int i=NDIM;i--;) {
    233       l = TopReplacement->x.x[i] - TopOrigin->x.x[i];
     235      l = TopReplacement->x[i] - TopOrigin->x[i];
    234236      if (fabs(l) > BondDistance) { // is component greater than bond distance
    235         Orthovector1.x[i] = (l < 0) ? -1. : +1.;
     237        Orthovector1[i] = (l < 0) ? -1. : +1.;
    236238      } // (signs are correct, was tested!)
    237239    }
     
    305307
    306308        // determine the plane of these two with the *origin
    307         AllWentWell = AllWentWell && Orthovector1.MakeNormalVector(&TopOrigin->x, &FirstOtherAtom->x, &SecondOtherAtom->x);
     309        try {
     310          Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
     311        }
     312        catch(LinearDependenceException &excp){
     313          Log() << Verbose(0) << excp;
     314          // TODO: figure out what to do with the Orthovector in this case
     315          AllWentWell = false;
     316        }
    308317      } else {
    309318        Orthovector1.GetOneNormalVector(&InBondvector);
     
    313322      //Log() << Verbose(0) << endl;
    314323      // orthogonal vector and bond vector between origin and replacement form the new plane
    315       Orthovector1.MakeNormalVector(&InBondvector);
     324      Orthovector1.MakeNormalTo(InBondvector);
    316325      Orthovector1.Normalize();
    317326      //Log() << Verbose(3) << "ReScaleCheck: " << Orthovector1.Norm() << " and " << InBondvector.Norm() << "." << endl;
     
    345354      SecondOtherAtom->x.Zero();
    346355      for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
    347         FirstOtherAtom->x.x[i] = InBondvector.x[i] * cos(bondangle) + Orthovector1.x[i] * (sin(bondangle));
    348         SecondOtherAtom->x.x[i] = InBondvector.x[i] * cos(bondangle) + Orthovector1.x[i] * (-sin(bondangle));
     356        FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
     357        SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
    349358      }
    350359      FirstOtherAtom->x.Scale(&BondRescale);  // rescale by correct BondDistance
     
    352361      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    353362      for(int i=NDIM;i--;) { // and make relative to origin atom
    354         FirstOtherAtom->x.x[i] += TopOrigin->x.x[i];
    355         SecondOtherAtom->x.x[i] += TopOrigin->x.x[i];
     363        FirstOtherAtom->x[i] += TopOrigin->x[i];
     364        SecondOtherAtom->x[i] += TopOrigin->x[i];
    356365      }
    357366      // ... and add to molecule
     
    394403//      Orthovector1.Output(out);
    395404//      Log() << Verbose(0) << endl;
    396       AllWentWell = AllWentWell && Orthovector2.MakeNormalVector(&InBondvector, &Orthovector1);
     405      try{
     406        Orthovector2 = Plane(InBondvector, Orthovector1,0).getNormal();
     407      }
     408      catch(LinearDependenceException &excp) {
     409        Log() << Verbose(0) << excp;
     410        AllWentWell = false;
     411      }
    397412//      Log() << Verbose(3) << "Orthovector2: ";
    398413//      Orthovector2.Output(out);
     
    514529    }
    515530    for(j=NDIM;j--;) {
    516       Walker->x.x[j] = x[j];
    517       Walker->Trajectory.R.at(MDSteps-1).x[j] = x[j];
    518       Walker->Trajectory.U.at(MDSteps-1).x[j] = 0;
    519       Walker->Trajectory.F.at(MDSteps-1).x[j] = 0;
     531      Walker->x[j] = x[j];
     532      Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
     533      Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
     534      Walker->Trajectory.F.at(MDSteps-1)[j] = 0;
    520535    }
    521536    AddAtom(Walker);  // add to molecule
     
    661676void molecule::SetBoxDimension(Vector *dim)
    662677{
    663   cell_size[0] = dim->x[0];
     678  cell_size[0] = dim->at(0);
    664679  cell_size[1] = 0.;
    665   cell_size[2] = dim->x[1];
     680  cell_size[2] = dim->at(1);
    666681  cell_size[3] = 0.;
    667682  cell_size[4] = 0.;
    668   cell_size[5] = dim->x[2];
     683  cell_size[5] = dim->at(2);
    669684};
    670685
     
    755770  for (int i=0;i<NDIM;i++) {
    756771    j += i+1;
    757     result = result && ((x->x[i] >= 0) && (x->x[i] < cell_size[j]));
     772    result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j]));
    758773  }
    759774  //return result;
     
    10051020    DeterminePeriodicCenter(CenterOfGravity);
    10061021    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    1007     Log() << Verbose(5) << "Center of Gravity: ";
    1008     CenterOfGravity.Output();
    1009     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
    1010     OtherCenterOfGravity.Output();
    1011     Log() << Verbose(0) << endl;
     1022    Log() << Verbose(5) << "Center of Gravity: " << CenterOfGravity << endl;
     1023    Log() << Verbose(5) << "Other Center of Gravity: " << OtherCenterOfGravity << endl;
    10121024    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    10131025      Log() << Verbose(4) << "Centers of gravity don't match." << endl;
  • src/molecule_dynamics.cpp

    rf9352d r0a4f7f  
    1414#include "molecule.hpp"
    1515#include "parser.hpp"
     16#include "Plane.hpp"
    1617
    1718/************************************* Functions for class molecule *********************************/
     
    7980  //        Log() << Verbose(0) << trajectory2 << endl;
    8081      // determine normal vector for both
    81       normal.MakeNormalVector(&trajectory1, &trajectory2);
     82      normal = Plane(trajectory1, trajectory2,0).getNormal();
    8283      // print all vectors for debugging
    8384  //        Log() << Verbose(0) << "Normal vector in between: ";
     
    8586      // setup matrix
    8687      for (int i=NDIM;i--;) {
    87         gsl_matrix_set(A, 0, i, trajectory1.x[i]);
    88         gsl_matrix_set(A, 1, i, trajectory2.x[i]);
    89         gsl_matrix_set(A, 2, i, normal.x[i]);
    90         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep).x[i] - Runner->Trajectory.R.at(Params.startstep).x[i]));
     88        gsl_matrix_set(A, 0, i, trajectory1[i]);
     89        gsl_matrix_set(A, 1, i, trajectory2[i]);
     90        gsl_matrix_set(A, 2, i, normal[i]);
     91        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));
    9192      }
    9293      // solve the linear system by Householder transformations
     
    514515      Sprinter = mol->AddCopyAtom(Walker);
    515516      for (int n=NDIM;n--;) {
    516         Sprinter->x.x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
     517        Sprinter->x[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    517518        // add to Trajectories
    518519        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    519520        if (step < MaxSteps) {
    520           Walker->Trajectory.R.at(step).x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
    521           Walker->Trajectory.U.at(step).x[n] = 0.;
    522           Walker->Trajectory.F.at(step).x[n] = 0.;
     521          Walker->Trajectory.R.at(step)[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     522          Walker->Trajectory.U.at(step)[n] = 0.;
     523          Walker->Trajectory.F.at(step)[n] = 0.;
    523524        }
    524525      }
     
    582583    for(int i=0;i<AtomCount;i++)
    583584      for(int d=0;d<NDIM;d++) {
    584         Velocity.x[d] += Force.Matrix[0][i][d+5];
     585        Velocity[d] += Force.Matrix[0][i][d+5];
    585586      }
    586587    for(int i=0;i<AtomCount;i++)
    587588      for(int d=0;d<NDIM;d++) {
    588         Force.Matrix[0][i][d+5] -= Velocity.x[d]/(double)AtomCount;
     589        Force.Matrix[0][i][d+5] -= Velocity[d]/(double)AtomCount;
    589590      }
    590591    // solve a constrained potential if we are meant to
  • src/molecule_fragmentation.cpp

    rf9352d r0a4f7f  
    16691669    // remove bonds that are beyond bonddistance
    16701670    for(int i=NDIM;i--;)
    1671       Translationvector.x[i] = 0.;
     1671      Translationvector[i] = 0.;
    16721672    // scan all bonds
    16731673    Binder = first;
     
    16761676      Binder = Binder->next;
    16771677      for (int i=NDIM;i--;) {
    1678         tmp = fabs(Binder->leftatom->x.x[i] - Binder->rightatom->x.x[i]);
     1678        tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
    16791679        //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
    16801680        if (tmp > BondDistance) {
     
    16901690      // create translation vector from their periodically modified distance
    16911691      for (int i=NDIM;i--;) {
    1692         tmp = Binder->leftatom->x.x[i] - Binder->rightatom->x.x[i];
     1692        tmp = Binder->leftatom->x[i] - Binder->rightatom->x[i];
    16931693        if (fabs(tmp) > BondDistance)
    1694           Translationvector.x[i] = (tmp < 0) ? +1. : -1.;
     1694          Translationvector[i] = (tmp < 0) ? +1. : -1.;
    16951695      }
    16961696      Translationvector.MatrixMultiplication(matrix);
    16971697      //Log() << Verbose(3) << "Translation vector is ";
    1698       Translationvector.Output();
    1699       Log() << Verbose(0) << endl;
     1698      Log() << Verbose(0) << Translationvector <<  endl;
    17001699      // apply to all atoms of first component via BFS
    17011700      for (int i=AtomCount;i--;)
  • src/molecule_geometry.cpp

    rf9352d r0a4f7f  
    6969  if (ptr != end) {   //list not empty?
    7070    for (int i=NDIM;i--;) {
    71       max->x[i] = ptr->x.x[i];
    72       min->x[i] = ptr->x.x[i];
     71      max->at(i) = ptr->x[i];
     72      min->at(i) = ptr->x[i];
    7373    }
    7474    while (ptr->next != end) {  // continue with second if present
     
    7676      //ptr->Output(1,1,out);
    7777      for (int i=NDIM;i--;) {
    78         max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i];
    79         min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i];
     78        max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);
     79        min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);
    8080      }
    8181    }
     
    272272         if (Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing
    273273            for (int j=0;j<NDIM;j++) {
    274               tmp = Walker->x.x[j] - (*Runner)->GetOtherAtom(Walker)->x.x[j];
     274              tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];
    275275              if ((fabs(tmp)) > BondDistance) {
    276276                flag = false;
    277277                Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;
    278278                if (tmp > 0)
    279                   Translationvector.x[j] -= 1.;
     279                  Translationvector[j] -= 1.;
    280280                else
    281                   Translationvector.x[j] += 1.;
     281                  Translationvector[j] += 1.;
    282282              }
    283283            }
     
    286286        Testvector.MatrixMultiplication(matrix);
    287287        Center.AddVector(&Testvector);
    288         Log() << Verbose(1) << "vector is: ";
    289         Testvector.Output();
    290         Log() << Verbose(0) << endl;
     288        Log() << Verbose(1) << "vector is: " << Testvector << endl;
    291289#ifdef ADDHYDROGEN
    292290        // now also change all hydrogens
     
    298296            Testvector.MatrixMultiplication(matrix);
    299297            Center.AddVector(&Testvector);
    300             Log() << Verbose(1) << "Hydrogen vector is: ";
    301             Testvector.Output();
    302             Log() << Verbose(0) << endl;
     298            Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
    303299          }
    304300        }
     
    336332    x.CopyVector(&ptr->x);
    337333    //x.SubtractVector(CenterOfGravity);
    338     InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
    339     InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
    340     InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
    341     InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
    342     InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
    343     InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
    344     InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
    345     InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
    346     InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
     334    InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     335    InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
     336    InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
     337    InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
     338    InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
     339    InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
     340    InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
     341    InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
     342    InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
    347343  }
    348344  // print InertiaTensor for debugging
     
    388384      x.CopyVector(&ptr->x);
    389385      //x.SubtractVector(CenterOfGravity);
    390       InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
    391       InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
    392       InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
    393       InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
    394       InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
    395       InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
    396       InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
    397       InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
    398       InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
     386      InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     387      InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
     388      InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
     389      InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
     390      InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
     391      InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
     392      InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
     393      InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
     394      InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
    399395    }
    400396    // print InertiaTensor for debugging
     
    423419  double alpha, tmp;
    424420  Vector z_axis;
    425   z_axis.x[0] = 0.;
    426   z_axis.x[1] = 0.;
    427   z_axis.x[2] = 1.;
     421  z_axis[0] = 0.;
     422  z_axis[1] = 0.;
     423  z_axis[2] = 1.;
    428424
    429425  // rotate on z-x plane
    430426  Log() << Verbose(0) << "Begin of Aligning all atoms." << endl;
    431   alpha = atan(-n->x[0]/n->x[2]);
     427  alpha = atan(-n->at(0)/n->at(2));
    432428  Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";
    433429  while (ptr->next != end) {
    434430    ptr = ptr->next;
    435     tmp = ptr->x.x[0];
    436     ptr->x.x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x.x[2];
    437     ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2];
     431    tmp = ptr->x[0];
     432    ptr->x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
     433    ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
    438434    for (int j=0;j<MDSteps;j++) {
    439       tmp = ptr->Trajectory.R.at(j).x[0];
    440       ptr->Trajectory.R.at(j).x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];
    441       ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];
     435      tmp = ptr->Trajectory.R.at(j)[0];
     436      ptr->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
     437      ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
    442438    }
    443439  }
    444440  // rotate n vector
    445   tmp = n->x[0];
    446   n->x[0] =  cos(alpha) * tmp +  sin(alpha) * n->x[2];
    447   n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    448   Log() << Verbose(1) << "alignment vector after first rotation: ";
    449   n->Output();
    450   Log() << Verbose(0) << endl;
     441  tmp = n->at(0);
     442  n->at(0) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
     443  n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
     444  Log() << Verbose(1) << "alignment vector after first rotation: " << n << endl;
    451445
    452446  // rotate on z-y plane
    453447  ptr = start;
    454   alpha = atan(-n->x[1]/n->x[2]);
     448  alpha = atan(-n->at(1)/n->at(2));
    455449  Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";
    456450  while (ptr->next != end) {
    457451    ptr = ptr->next;
    458     tmp = ptr->x.x[1];
    459     ptr->x.x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x.x[2];
    460     ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2];
     452    tmp = ptr->x[1];
     453    ptr->x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
     454    ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
    461455    for (int j=0;j<MDSteps;j++) {
    462       tmp = ptr->Trajectory.R.at(j).x[1];
    463       ptr->Trajectory.R.at(j).x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];
    464       ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];
     456      tmp = ptr->Trajectory.R.at(j)[1];
     457      ptr->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
     458      ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
    465459    }
    466460  }
    467461  // rotate n vector (for consistency check)
    468   tmp = n->x[1];
    469   n->x[1] =  cos(alpha) * tmp +  sin(alpha) * n->x[2];
    470   n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    471 
    472   Log() << Verbose(1) << "alignment vector after second rotation: ";
    473   n->Output();
    474   Log() << Verbose(1) << endl;
     462  tmp = n->at(1);
     463  n->at(1) =  cos(alpha) * tmp +  sin(alpha) * n->at(2);
     464  n->at(2) = -sin(alpha) * tmp +  cos(alpha) * n->at(2);
     465
     466  Log() << Verbose(1) << "alignment vector after second rotation: " << n << endl;
    475467  Log() << Verbose(0) << "End of Aligning all atoms." << endl;
    476468};
     
    490482
    491483  // initialize vectors
    492   a.x[0] = gsl_vector_get(x,0);
    493   a.x[1] = gsl_vector_get(x,1);
    494   a.x[2] = gsl_vector_get(x,2);
    495   b.x[0] = gsl_vector_get(x,3);
    496   b.x[1] = gsl_vector_get(x,4);
    497   b.x[2] = gsl_vector_get(x,5);
     484  a[0] = gsl_vector_get(x,0);
     485  a[1] = gsl_vector_get(x,1);
     486  a[2] = gsl_vector_get(x,2);
     487  b[0] = gsl_vector_get(x,3);
     488  b[1] = gsl_vector_get(x,4);
     489  b[2] = gsl_vector_get(x,5);
    498490  // go through all atoms
    499491  while (ptr != par->mol->end) {
  • src/molecule_graph.cpp

    rf9352d r0a4f7f  
    1717#include "memoryallocator.hpp"
    1818#include "molecule.hpp"
     19#include "Helpers/fast_functions.hpp"
    1920
    2021struct BFSAccounting
  • src/moleculelist.cpp

    rf9352d r0a4f7f  
    681681    for (int k = 0; k < NDIM; k++) {
    682682      j += k + 1;
    683       BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    684       (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;
     683      BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
     684      (*ListRunner)->cell_size[j] += BoxDimension[k] * 2.;
    685685    }
    686686    (*ListRunner)->Translate(&BoxDimension);
     
    908908  // center at set box dimensions
    909909  mol->CenterEdge(&center);
    910   mol->cell_size[0] = center.x[0];
     910  mol->cell_size[0] = center[0];
    911911  mol->cell_size[1] = 0;
    912   mol->cell_size[2] = center.x[1];
     912  mol->cell_size[2] = center[1];
    913913  mol->cell_size[3] = 0;
    914914  mol->cell_size[4] = 0;
    915   mol->cell_size[5] = center.x[2];
     915  mol->cell_size[5] = center[2];
    916916  insert(mol);
    917917}
  • src/tesselation.cpp

    rf9352d r0a4f7f  
    1515#include "tesselationhelpers.hpp"
    1616#include "vector.hpp"
     17#include "vector_ops.hpp"
    1718#include "verbose.hpp"
     19#include "Plane.hpp"
     20#include "Exceptions/LinearDependenceException.hpp"
    1821
    1922class molecule;
     
    258261      helper[i].CopyVector(node->node->node);
    259262      helper[i].SubtractVector(&BaseLineCenter);
    260       helper[i].MakeNormalVector(&BaseLine);  // we want to compare the triangle's heights' angles!
     263      helper[i].MakeNormalTo(BaseLine);  // we want to compare the triangle's heights' angles!
    261264      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
    262265      i++;
     
    402405        Info FunctionInfo(__func__);
    403406  // get normal vector
    404   NormalVector.MakeNormalVector(endpoints[0]->node->node, endpoints[1]->node->node, endpoints[2]->node->node);
     407  NormalVector = Plane(*(endpoints[0]->node->node),
     408                       *(endpoints[1]->node->node),
     409                       *(endpoints[2]->node->node)).getNormal();
    405410
    406411  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
     
    428433  Vector helper;
    429434
    430   if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) {
     435  try {
     436    *Intersection = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*MolCenter, *x);
     437  }
     438  catch (LinearDependenceException &excp) {
     439    Log() << Verbose(1) << excp;
    431440    eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;
    432441    return false;
     
    450459  int i=0;
    451460  do {
    452     if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {
     461    try {
     462      CrossPoint = GetIntersectionOfTwoLinesOnPlane(*(endpoints[i%3]->node->node),
     463                                                    *(endpoints[(i+1)%3]->node->node),
     464                                                    *(endpoints[(i+2)%3]->node->node),
     465                                                    *Intersection);
    453466      helper.CopyVector(endpoints[(i+1)%3]->node->node);
    454467      helper.SubtractVector(endpoints[i%3]->node->node);
     
    462475      }
    463476      i++;
    464     } else
     477    } catch (LinearDependenceException &excp){
    465478      break;
     479    }
    466480  } while (i<3);
    467481  if (i==3) {
     
    492506  Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl;
    493507  GetCenter(&Direction);
    494   if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) {
     508  try {
     509    *ClosestPoint = Plane(NormalVector, *(endpoints[0]->node->node)).GetIntersection(*x, Direction);
     510  }
     511  catch (LinearDependenceException &excp) {
    495512    ClosestPoint->CopyVector(x);
    496513  }
     
    518535    Direction.SubtractVector(endpoints[i%3]->node->node);
    519536    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    520     CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node);
     537
     538    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));
     539
    521540    CrossDirection[i].CopyVector(&CrossPoint[i]);
    522541    CrossDirection[i].SubtractVector(&InPlane);
     
    731750  int counter=0;
    732751  for (; Runner[2] != endpoints.end(); ) {
    733     TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node);
     752    TemporaryNormal = Plane(*((*Runner[0])->node->node),
     753                            *((*Runner[1])->node->node),
     754                            *((*Runner[2])->node->node)).getNormal();
    734755    for (int i=0;i<3;i++) // increase each of them
    735756      Runner[i]++;
     
    12201241      // 2. next, we have to check whether all points reside on only one side of the triangle
    12211242      // 3. construct plane vector
    1222       PlaneVector.MakeNormalVector(A->second->node->node,
    1223           baseline->second.first->second->node->node,
    1224           baseline->second.second->second->node->node);
     1243      PlaneVector = Plane(*(A->second->node->node),
     1244                          *(baseline->second.first->second->node->node),
     1245                          *(baseline->second.second->second->node->node)).getNormal();
    12251246      Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl;
    12261247      // 4. loop over all points
     
    13911412        // vector in propagation direction (out of triangle)
    13921413        // project center vector onto triangle plane (points from intersection plane-NormalVector to plane-CenterVector intersection)
    1393         PropagationVector.MakeNormalVector(&BaseLine, &NormalVector);
     1414        PropagationVector = Plane(BaseLine, NormalVector,0).getNormal();
    13941415        TempVector.CopyVector(&CenterVector);
    13951416        TempVector.SubtractVector(baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
     
    14481469            // in case NOT both were found, create virtually this triangle, get its normal vector, calculate angle
    14491470            flag = true;
    1450             VirtualNormalVector.MakeNormalVector(baseline->second->endpoints[0]->node->node, baseline->second->endpoints[1]->node->node, target->second->node->node);
     1471            VirtualNormalVector = Plane(*(baseline->second->endpoints[0]->node->node),
     1472                                        *(baseline->second->endpoints[1]->node->node),
     1473                                        *(target->second->node->node)).getNormal();
    14511474            TempVector.CopyVector(baseline->second->endpoints[0]->node->node);
    14521475            TempVector.AddVector(baseline->second->endpoints[1]->node->node);
     
    20632086        if (List != NULL) {
    20642087          for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) {
    2065             if ((*Runner)->node->x[i] > maxCoordinate[i]) {
     2088            if ((*Runner)->node->at(i) > maxCoordinate[i]) {
    20662089              Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;
    2067               maxCoordinate[i] = (*Runner)->node->x[i];
     2090              maxCoordinate[i] = (*Runner)->node->at(i);
    20682091              MaxPoint[i] = (*Runner);
    20692092            }
     
    20832106  for (int k=0;k<NDIM;k++) {
    20842107    NormalVector.Zero();
    2085     NormalVector.x[k] = 1.;
     2108    NormalVector[k] = 1.;
    20862109    BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
    20872110    Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
     
    21172140
    21182141    // look in one direction of baseline for initial candidate
    2119     SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector);  // whether we look "left" first or "right" first is not important ...
     2142    SearchDirection = Plane(CirclePlaneNormal, NormalVector,0).getNormal();  // whether we look "left" first or "right" first is not important ...
    21202143
    21212144    // adding point 1 and point 2 and add the line between them
     
    23362359
    23372360    // construct SearchDirection and an "outward pointer"
    2338     SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal);
     2361    SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal();
    23392362    helper.CopyVector(&CircleCenter);
    23402363    helper.SubtractVector(ThirdNode->node);
     
    29793002                  Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl;
    29803003
    2981                   if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)
    2982                   && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)
    2983                   ) {
     3004                  try {
     3005                    NewNormalVector = Plane(*(CandidateLine.BaseLine->endpoints[0]->node->node),
     3006                                              *(CandidateLine.BaseLine->endpoints[1]->node->node),
     3007                                              *(Candidate->node)).getNormal();
     3008
     3009                    if(!fabs(NewNormalVector.NormSquared()) > HULLEPSILON)
     3010                      throw LinearDependenceException(__FILE__,__LINE__);
     3011
    29843012                    Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;
    29853013                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter);
     
    30433071                      Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;
    30443072                    }
    3045                   } else {
     3073                  }
     3074                  catch (LinearDependenceException &excp){
     3075                    Log() << Verbose(1) << excp;
    30463076                    Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;
    30473077                  }
     
    35653595  Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
    35663596  if (AngleZero.NormSquared() > MYEPSILON)
    3567     OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
     3597    OrthogonalVector = Plane(PlaneNormal, AngleZero,0).getNormal();
    35683598  else
    3569     OrthogonalVector.MakeNormalVector(&PlaneNormal);
     3599    OrthogonalVector.MakeNormalTo(PlaneNormal);
    35703600  Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
    35713601
     
    36333663  int counter = 0;
    36343664  while (TesselC != SetOfNeighbours->end()) {
    3635     helper.MakeNormalVector((*TesselA)->node, (*TesselB)->node, (*TesselC)->node);
     3665    helper = Plane(*((*TesselA)->node),
     3666                   *((*TesselB)->node),
     3667                   *((*TesselC)->node)).getNormal();
    36363668    Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl;
    36373669    counter++;
     
    36703702  Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
    36713703  if (AngleZero.NormSquared() > MYEPSILON)
    3672     OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
     3704    OrthogonalVector = Plane(PlaneNormal, AngleZero,0).getNormal();
    36733705  else
    3674     OrthogonalVector.MakeNormalVector(&PlaneNormal);
     3706    OrthogonalVector.MakeNormalTo(PlaneNormal);
    36753707  Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
    36763708
     
    40024034          OrthogonalVector.CopyVector((*MiddleNode)->node);
    40034035          OrthogonalVector.SubtractVector(&OldPoint);
    4004           OrthogonalVector.MakeNormalVector(&Reference);
     4036          OrthogonalVector.MakeNormalTo(Reference);
    40054037          angle = GetAngle(Point, Reference, OrthogonalVector);
    40064038          //if (angle < M_PI)  // no wrong-sided triangles, please?
  • src/tesselationhelpers.cpp

    rf9352d r0a4f7f  
    1414#include "tesselationhelpers.hpp"
    1515#include "vector.hpp"
     16#include "vector_ops.hpp"
    1617#include "verbose.hpp"
    1718
     
    5354
    5455  for(int i=0;i<3;i++) {
    55     gsl_matrix_set(A, i, 0, a.x[i]);
    56     gsl_matrix_set(A, i, 1, b.x[i]);
    57     gsl_matrix_set(A, i, 2, c.x[i]);
     56    gsl_matrix_set(A, i, 0, a[i]);
     57    gsl_matrix_set(A, i, 1, b[i]);
     58    gsl_matrix_set(A, i, 2, c[i]);
    5859  }
    5960  m11 = DetGet(A, 1);
    6061
    6162  for(int i=0;i<3;i++) {
    62     gsl_matrix_set(A, i, 0, a.x[i]*a.x[i] + b.x[i]*b.x[i] + c.x[i]*c.x[i]);
    63     gsl_matrix_set(A, i, 1, b.x[i]);
    64     gsl_matrix_set(A, i, 2, c.x[i]);
     63    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     64    gsl_matrix_set(A, i, 1, b[i]);
     65    gsl_matrix_set(A, i, 2, c[i]);
    6566  }
    6667  m12 = DetGet(A, 1);
    6768
    6869  for(int i=0;i<3;i++) {
    69     gsl_matrix_set(A, i, 0, a.x[i]*a.x[i] + b.x[i]*b.x[i] + c.x[i]*c.x[i]);
    70     gsl_matrix_set(A, i, 1, a.x[i]);
    71     gsl_matrix_set(A, i, 2, c.x[i]);
     70    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     71    gsl_matrix_set(A, i, 1, a[i]);
     72    gsl_matrix_set(A, i, 2, c[i]);
    7273  }
    7374  m13 = DetGet(A, 1);
    7475
    7576  for(int i=0;i<3;i++) {
    76     gsl_matrix_set(A, i, 0, a.x[i]*a.x[i] + b.x[i]*b.x[i] + c.x[i]*c.x[i]);
    77     gsl_matrix_set(A, i, 1, a.x[i]);
    78     gsl_matrix_set(A, i, 2, b.x[i]);
     77    gsl_matrix_set(A, i, 0, a[i]*a[i] + b[i]*b[i] + c[i]*c[i]);
     78    gsl_matrix_set(A, i, 1, a[i]);
     79    gsl_matrix_set(A, i, 2, b[i]);
    7980  }
    8081  m14 = DetGet(A, 1);
     
    8384    eLog() << Verbose(1) << "three points are colinear." << endl;
    8485
    85   center->x[0] =  0.5 * m12/ m11;
    86   center->x[1] = -0.5 * m13/ m11;
    87   center->x[2] =  0.5 * m14/ m11;
     86  center->at(0) =  0.5 * m12/ m11;
     87  center->at(1) = -0.5 * m13/ m11;
     88  center->at(2) =  0.5 * m14/ m11;
    8889
    8990  if (fabs(a.Distance(center) - RADIUS) > MYEPSILON)
     
    281282  Vector SideA,SideB,HeightA, HeightB;
    282283  for (int i=0;i<NDIM;i++)
    283     intersection.x[i] = gsl_vector_get(x, i);
     284    intersection[i] = gsl_vector_get(x, i);
    284285
    285286  SideA.CopyVector(&(I->x1));
     
    336337    /* Starting point */
    337338    x = gsl_vector_alloc(NDIM);
    338     gsl_vector_set(x, 0, point1.x[0]);
    339     gsl_vector_set(x, 1, point1.x[1]);
    340     gsl_vector_set(x, 2, point1.x[2]);
     339    gsl_vector_set(x, 0, point1[0]);
     340    gsl_vector_set(x, 1, point1[1]);
     341    gsl_vector_set(x, 2, point1[2]);
    341342
    342343    /* Set initial step sizes to 1 */
     
    372373  double t1, t2;
    373374  for (int i = 0; i < NDIM; i++) {
    374     intersection.x[i] = gsl_vector_get(s->x, i);
     375    intersection[i] = gsl_vector_get(s->x, i);
    375376  }
    376377
     
    700701  // calculate the intersection between this projected baseline and Base
    701702  Vector *Intersection = new Vector;
    702   Intersection->GetIntersectionOfTwoLinesOnPlane(Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &NewDirection, &Normal);
     703  *Intersection = GetIntersectionOfTwoLinesOnPlane(*(Base->endpoints[0]->node->node),
     704                                                   *(Base->endpoints[1]->node->node),
     705                                                     NewOffset, NewDirection);
    703706  Normal.CopyVector(Intersection);
    704707  Normal.SubtractVector(Base->endpoints[0]->node->node);
     
    747750      *vrmlfile << "Sphere {" << endl << "  "; // 2 is sphere type
    748751      for (i=0;i<NDIM;i++)
    749         *vrmlfile << Walker->node->x[i]-center->x[i] << " ";
     752        *vrmlfile << Walker->node->at(i)-center->at(i) << " ";
    750753      *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    751754      cloud->GoToNext();
     
    757760      for (i=0;i<3;i++) { // print each node
    758761        for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    759           *vrmlfile << TriangleRunner->second->endpoints[i]->node->node->x[j]-center->x[j] << " ";
     762          *vrmlfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
    760763        *vrmlfile << "\t";
    761764      }
     
    792795    *rasterfile << "# current virtual sphere\n";
    793796    *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
    794     *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
     797    *rasterfile << "2\n  " << helper[0] << " " << helper[1] << " " << helper[2] << "\t" << 5. << "\t1 0 0\n";
    795798    *rasterfile << "9\n  terminating special property\n";
    796799    delete(center);
     
    820823      *rasterfile << "2" << endl << "  ";  // 2 is sphere type
    821824      for (i=0;i<NDIM;i++)
    822         *rasterfile << Walker->node->x[i]-center->x[i] << " ";
     825        *rasterfile << Walker->node->at(i)-center->at(i) << " ";
    823826      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    824827      cloud->GoToNext();
     
    831834      for (i=0;i<3;i++) {  // print each node
    832835        for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    833           *rasterfile << TriangleRunner->second->endpoints[i]->node->node->x[j]-center->x[j] << " ";
     836          *rasterfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
    834837        *rasterfile << "\t";
    835838      }
     
    877880      Walker = target->second->node;
    878881      LookupList[Walker->nr] = Counter++;
    879       *tecplot << Walker->node->x[0] << " " << Walker->node->x[1] << " " << Walker->node->x[2] << " " << target->second->value << endl;
     882      *tecplot << Walker->node->at(0) << " " << Walker->node->at(1) << " " << Walker->node->at(2) << " " << target->second->value << endl;
    880883    }
    881884    *tecplot << endl;
  • src/unittests/ActOnAllUnitTest.cpp

    rf9352d r0a4f7f  
    9999};
    100100
     101#if 0
     102
     103// Unitttest deactivated for now...
     104// Reasons:
     105//    Vector::MakeNormalVector has been removed and is now part of Plane class
     106//    VectorList::ActOnAll is in the test directory and seems to be used only for unittests
     107//    MakeNormal never depended on the input Vector except in the case of linear dependence (i.e. failure)
     108//
     109// TODO: Rethink what exactely is being tested at this point and introduce a new unittest for the
     110//       tested behaviour. Most likely this should result in a thourough unittest of the plane class
     111
    101112/** UnitTest for VectorList::ActOnAll() and Vector::MakeNormalVector()
    102113 */
     
    113124  // check that x and y components are zero
    114125  for (ListOfVectors::iterator Runner = VL.Vectors.begin(); Runner != VL.Vectors.end(); Runner++) {
    115     CPPUNIT_ASSERT_EQUAL( (*Runner)->x[0] , 0. );
    116     CPPUNIT_ASSERT_EQUAL( (*Runner)->x[1] , 0. );
     126    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(0) , 0. );
     127    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(1) , 0. );
    117128  }
    118129};
     130
     131#endif
  • src/unittests/ActOnAllUnitTest.hpp

    rf9352d r0a4f7f  
    2020    CPPUNIT_TEST ( AddSubtractTest );
    2121    CPPUNIT_TEST ( ScaleTest );
     22#if 0
     23    // test deactivated. See .cpp for reasons and workarounds
    2224    CPPUNIT_TEST ( NormalizeTest );
     25#endif
    2326    CPPUNIT_TEST_SUITE_END();
    2427
  • src/unittests/vectorunittest.cpp

    rf9352d r0a4f7f  
    1717#include "memoryusageobserver.hpp"
    1818#include "vector.hpp"
     19#include "vector_ops.hpp"
    1920#include "vectorunittest.hpp"
     21#include "Plane.hpp"
     22#include "Exceptions/LinearDependenceException.hpp"
    2023
    2124#ifdef HAVE_TESTRUNNER
     
    195198{
    196199  // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    197   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionWithPlane(&unit, &zero, &zero, &two) );
     200  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) );
    198201  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    199202
    200203  // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???
    201   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionWithPlane(&otherunit, &two, &unit, &notunit) );
     204  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) );
    202205  CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );
    203206
    204207  // four vectors equal to zero
    205   CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&zero, &zero, &zero, &zero, NULL) );
     208  CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException);
     209  //CPPUNIT_ASSERT_EQUAL( zero, fixture );
     210
     211  // four vectors equal to unit
     212  CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException);
     213  //CPPUNIT_ASSERT_EQUAL( zero, fixture );
     214
     215  // two equal lines
     216  CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two));
     217  CPPUNIT_ASSERT_EQUAL( unit, fixture );
     218
     219  // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???
     220  CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) );
     221  CPPUNIT_ASSERT_EQUAL( unit, fixture );
     222
     223  // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???
     224  CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) );
    206225  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    207226
    208   // four vectors equal to unit
    209   CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &unit, &unit, &unit, NULL) );
     227  // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???
     228  CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) );
     229  CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );
     230};
     231
     232/** UnitTest for vector rotations.
     233 */
     234void VectorTest::VectorRotationTest()
     235{
     236  fixture.Init(-1.,0.,0.);
     237
     238  // zero vector does not change
     239  fixture = RotateVector(zero,unit, 1.);
    210240  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    211241
    212   // two equal lines
    213   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &two, NULL) );
     242  fixture = RotateVector(zero, two, 1.);
     243  CPPUNIT_ASSERT_EQUAL( zero,  fixture);
     244
     245  // vector on axis does not change
     246  fixture = RotateVector(unit,unit, 1.);
    214247  CPPUNIT_ASSERT_EQUAL( unit, fixture );
    215248
    216   // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???
    217   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &otherunit, NULL) );
    218   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    219 
    220   // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    221   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &zero, &zero, &two, NULL) );
    222   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    223 
    224   // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???
    225   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &zero, &otherunit, NULL) );
    226   CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );
    227 };
    228 
    229 /** UnitTest for vector rotations.
    230  */
    231 void VectorTest::VectorRotationTest()
    232 {
    233   fixture.Init(-1.,0.,0.);
    234 
    235   // zero vector does not change
    236   fixture.CopyVector(&zero);
    237   fixture.RotateVector(&unit, 1.);
    238   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    239 
    240   fixture.RotateVector(&two, 1.);
    241   CPPUNIT_ASSERT_EQUAL( zero,  fixture);
    242 
    243   // vector on axis does not change
    244   fixture.CopyVector(&unit);
    245   fixture.RotateVector(&unit, 1.);
    246   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    247 
    248   fixture.RotateVector(&unit, 1.);
    249   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    250 
    251249  // rotations
    252   fixture.CopyVector(&otherunit);
    253   fixture.RotateVector(&unit, M_PI);
     250  fixture = RotateVector(otherunit, unit, M_PI);
    254251  CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture );
    255252
    256   fixture.CopyVector(&otherunit);
    257   fixture.RotateVector(&unit, 2. * M_PI);
     253  fixture = RotateVector(otherunit, unit, 2. * M_PI);
    258254  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    259255
    260   fixture.CopyVector(&otherunit);
    261   fixture.RotateVector(&unit, 0);
     256  fixture = RotateVector(otherunit,unit, 0);
    262257  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    263258
    264   fixture.Init(0.,0.,1.);
    265   fixture.RotateVector(&notunit, M_PI);
     259  fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI);
    266260  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    267261}
  • src/vector.cpp

    rf9352d r0a4f7f  
    77
    88#include "defs.hpp"
    9 #include "helpers.hpp"
    10 #include "info.hpp"
    119#include "gslmatrix.hpp"
    1210#include "leastsquaremin.hpp"
    13 #include "log.hpp"
    1411#include "memoryallocator.hpp"
    1512#include "vector.hpp"
    16 #include "verbose.hpp"
     13#include "Helpers/fast_functions.hpp"
     14#include "Helpers/Assert.hpp"
     15#include "Plane.hpp"
     16#include "Exceptions/LinearDependenceException.hpp"
    1717
    1818#include <gsl/gsl_linalg.h>
     
    2525/** Constructor of class vector.
    2626 */
    27 Vector::Vector() { x[0] = x[1] = x[2] = 0.; };
     27Vector::Vector()
     28{
     29  x[0] = x[1] = x[2] = 0.;
     30};
    2831
    2932/** Constructor of class vector.
    3033 */
    31 Vector::Vector(const double x1, const double x2, const double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };
     34Vector::Vector(const double x1, const double x2, const double x3)
     35{
     36  x[0] = x1;
     37  x[1] = x2;
     38  x[2] = x3;
     39};
     40
     41/**
     42 * Copy constructor
     43 */
     44Vector::Vector(const Vector& src)
     45{
     46  x[0] = src[0];
     47  x[1] = src[1];
     48  x[2] = src[2];
     49}
     50
     51/**
     52 * Assignment operator
     53 */
     54Vector& Vector::operator=(const Vector& src){
     55  // check for self assignment
     56  if(&src!=this){
     57    x[0] = src[0];
     58    x[1] = src[1];
     59    x[2] = src[2];
     60  }
     61  return *this;
     62}
    3263
    3364/** Desctructor of class vector.
     
    208239};
    209240
    210 /** Calculates the intersection point between a line defined by \a *LineVector and \a *LineVector2 and a plane defined by \a *Normal and \a *PlaneOffset.
    211  * According to [Bronstein] the vectorial plane equation is:
    212  *   -# \f$\stackrel{r}{\rightarrow} \cdot \stackrel{N}{\rightarrow} + D = 0\f$,
    213  * where \f$\stackrel{r}{\rightarrow}\f$ is the vector to be testet, \f$\stackrel{N}{\rightarrow}\f$ is the plane's normal vector and
    214  * \f$D = - \stackrel{a}{\rightarrow} \stackrel{N}{\rightarrow}\f$, the offset with respect to origin, if \f$\stackrel{a}{\rightarrow}\f$,
    215  * is an offset vector onto the plane. The line is parametrized by \f$\stackrel{x}{\rightarrow} + k \stackrel{t}{\rightarrow}\f$, where
    216  * \f$\stackrel{x}{\rightarrow}\f$ is the offset and \f$\stackrel{t}{\rightarrow}\f$ the directional vector (NOTE: No need to normalize
    217  * the latter). Inserting the parametrized form into the plane equation and solving for \f$k\f$, which we insert then into the parametrization
    218  * of the line yields the intersection point on the plane.
    219  * \param *out output stream for debugging
    220  * \param *PlaneNormal Plane's normal vector
    221  * \param *PlaneOffset Plane's offset vector
    222  * \param *Origin first vector of line
    223  * \param *LineVector second vector of line
    224  * \return true -  \a this contains intersection point on return, false - line is parallel to plane (even if in-plane)
    225  */
    226 bool Vector::GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector)
    227 {
    228   Info FunctionInfo(__func__);
    229   double factor;
    230   Vector Direction, helper;
    231 
    232   // find intersection of a line defined by Offset and Direction with a  plane defined by triangle
    233   Direction.CopyVector(LineVector);
    234   Direction.SubtractVector(Origin);
    235   Direction.Normalize();
    236   Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
    237   //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    238   factor = Direction.ScalarProduct(PlaneNormal);
    239   if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
    240     Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
    241     return false;
    242   }
    243   helper.CopyVector(PlaneOffset);
    244   helper.SubtractVector(Origin);
    245   factor = helper.ScalarProduct(PlaneNormal)/factor;
    246   if (fabs(factor) < MYEPSILON) { // Origin is in-plane
    247     Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
    248     CopyVector(Origin);
    249     return true;
    250   }
    251   //factor = Origin->ScalarProduct(PlaneNormal)*(-PlaneOffset->ScalarProduct(PlaneNormal))/(Direction.ScalarProduct(PlaneNormal));
    252   Direction.Scale(factor);
    253   CopyVector(Origin);
    254   Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
    255   AddVector(&Direction);
    256 
    257   // test whether resulting vector really is on plane
    258   helper.CopyVector(this);
    259   helper.SubtractVector(PlaneOffset);
    260   if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    261     Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
    262     return true;
    263   } else {
    264     eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;
    265     return false;
    266   }
    267 };
    268 
    269241/** Calculates the minimum distance of this vector to the plane.
    270242 * \param *out output stream for debugging
     
    280252  temp.CopyVector(this);
    281253  temp.SubtractVector(PlaneOffset);
    282   temp.MakeNormalVector(PlaneNormal);
     254  temp.MakeNormalTo(*PlaneNormal);
    283255  temp.Scale(-1.);
    284256  // then add connecting vector from plane to point
     
    292264
    293265  return (temp.Norm()*sign);
    294 };
    295 
    296 /** Calculates the intersection of the two lines that are both on the same plane.
    297  * This is taken from Weisstein, Eric W. "Line-Line Intersection." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html
    298  * \param *out output stream for debugging
    299  * \param *Line1a first vector of first line
    300  * \param *Line1b second vector of first line
    301  * \param *Line2a first vector of second line
    302  * \param *Line2b second vector of second line
    303  * \param *PlaneNormal normal of plane, is supplemental/arbitrary
    304  * \return true - \a this will contain the intersection on return, false - lines are parallel
    305  */
    306 bool Vector::GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal)
    307 {
    308   Info FunctionInfo(__func__);
    309 
    310   GSLMatrix *M = new GSLMatrix(4,4);
    311 
    312   M->SetAll(1.);
    313   for (int i=0;i<3;i++) {
    314     M->Set(0, i, Line1a->x[i]);
    315     M->Set(1, i, Line1b->x[i]);
    316     M->Set(2, i, Line2a->x[i]);
    317     M->Set(3, i, Line2b->x[i]);
    318   }
    319  
    320   //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
    321   //for (int i=0;i<4;i++) {
    322   //  for (int j=0;j<4;j++)
    323   //    cout << "\t" << M->Get(i,j);
    324   //  cout << endl;
    325   //}
    326   if (fabs(M->Determinant()) > MYEPSILON) {
    327     Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
    328     return false;
    329   }
    330   delete(M);
    331   Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
    332 
    333 
    334   // constuct a,b,c
    335   Vector a;
    336   Vector b;
    337   Vector c;
    338   Vector d;
    339   a.CopyVector(Line1b);
    340   a.SubtractVector(Line1a);
    341   b.CopyVector(Line2b);
    342   b.SubtractVector(Line2a);
    343   c.CopyVector(Line2a);
    344   c.SubtractVector(Line1a);
    345   d.CopyVector(Line2b);
    346   d.SubtractVector(Line1b);
    347   Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
    348   if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    349    Zero();
    350    Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
    351    return false;
    352   }
    353 
    354   // check for parallelity
    355   Vector parallel;
    356   double factor = 0.;
    357   if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
    358     parallel.CopyVector(Line1a);
    359     parallel.SubtractVector(Line2a);
    360     factor = parallel.ScalarProduct(&a)/a.Norm();
    361     if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    362       CopyVector(Line2a);
    363       Log() << Verbose(1) << "Lines conincide." << endl;
    364       return true;
    365     } else {
    366       parallel.CopyVector(Line1a);
    367       parallel.SubtractVector(Line2b);
    368       factor = parallel.ScalarProduct(&a)/a.Norm();
    369       if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    370         CopyVector(Line2b);
    371         Log() << Verbose(1) << "Lines conincide." << endl;
    372         return true;
    373       }
    374     }
    375     Log() << Verbose(1) << "Lines are parallel." << endl;
    376     Zero();
    377     return false;
    378   }
    379 
    380   // obtain s
    381   double s;
    382   Vector temp1, temp2;
    383   temp1.CopyVector(&c);
    384   temp1.VectorProduct(&b);
    385   temp2.CopyVector(&a);
    386   temp2.VectorProduct(&b);
    387   Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
    388   if (fabs(temp2.NormSquared()) > MYEPSILON)
    389     s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    390   else
    391     s = 0.;
    392   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
    393 
    394   // construct intersection
    395   CopyVector(&a);
    396   Scale(s);
    397   AddVector(Line1a);
    398   Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
    399 
    400   return true;
    401266};
    402267
     
    538403};
    539404
    540 /** Rotates the vector relative to the origin around the axis given by \a *axis by an angle of \a alpha.
    541  * \param *axis rotation axis
    542  * \param alpha rotation angle in radian
    543  */
    544 void Vector::RotateVector(const Vector * const axis, const double alpha)
    545 {
    546   Vector a,y;
    547   // normalise this vector with respect to axis
    548   a.CopyVector(this);
    549   a.ProjectOntoPlane(axis);
    550   // construct normal vector
    551   bool rotatable = y.MakeNormalVector(axis,&a);
    552   // The normal vector cannot be created if there is linar dependency.
    553   // Then the vector to rotate is on the axis and any rotation leads to the vector itself.
    554   if (!rotatable) {
    555     return;
    556   }
    557   y.Scale(Norm());
    558   // scale normal vector by sine and this vector by cosine
    559   y.Scale(sin(alpha));
    560   a.Scale(cos(alpha));
    561   CopyVector(Projection(axis));
    562   // add scaled normal vector onto this vector
    563   AddVector(&y);
    564   // add part in axis direction
    565   AddVector(&a);
    566 };
     405
     406double& Vector::operator[](size_t i){
     407  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
     408  return x[i];
     409}
     410
     411const double& Vector::operator[](size_t i) const{
     412  ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
     413  return x[i];
     414}
     415
     416double& Vector::at(size_t i){
     417  return (*this)[i];
     418}
     419
     420const double& Vector::at(size_t i) const{
     421  return (*this)[i];
     422}
     423
     424double* Vector::get(){
     425  return x;
     426}
    567427
    568428/** Compares vector \a to vector \a b component-wise.
     
    575435  bool status = true;
    576436  for (int i=0;i<NDIM;i++)
    577     status = status && (fabs(a.x[i] - b.x[i]) < MYEPSILON);
     437    status = status && (fabs(a[i] - b[i]) < MYEPSILON);
    578438  return status;
    579439};
     
    660520};
    661521
    662 /** Prints a 3dim vector.
    663  * prints no end of line.
    664  */
    665 void Vector::Output() const
    666 {
    667   Log() << Verbose(0) << "(";
    668   for (int i=0;i<NDIM;i++) {
    669     Log() << Verbose(0) << x[i];
    670     if (i != 2)
    671       Log() << Verbose(0) << ",";
    672   }
    673   Log() << Verbose(0) << ")";
    674 };
    675 
    676522ostream& operator<<(ostream& ost, const Vector& m)
    677523{
    678524  ost << "(";
    679525  for (int i=0;i<NDIM;i++) {
    680     ost << m.x[i];
     526    ost << m[i];
    681527    if (i != 2)
    682528      ost << ",";
     
    752598 * \param *matrix NDIM_NDIM array
    753599 */
    754 void Vector::InverseMatrixMultiplication(const double * const A)
     600bool Vector::InverseMatrixMultiplication(const double * const A)
    755601{
    756602  Vector C;
     
    779625    for (int i=NDIM;i--;)
    780626      x[i] = C.x[i];
     627    return true;
    781628  } else {
    782     eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;
     629    return false;
    783630  }
    784631};
     
    806653  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    807654  // withdraw projected vector twice from original one
    808   Log() << Verbose(1) << "Vector: ";
    809   Output();
    810   Log() << Verbose(0) << "\t";
    811655  for (int i=NDIM;i--;)
    812656    x[i] -= 2.*projection*n->x[i];
    813   Log() << Verbose(0) << "Projected vector: ";
    814   Output();
    815   Log() << Verbose(0) << endl;
    816 };
    817 
    818 /** Calculates normal vector for three given vectors (being three points in space).
    819  * Makes this vector orthonormal to the three given points, making up a place in 3d space.
    820  * \param *y1 first vector
    821  * \param *y2 second vector
    822  * \param *y3 third vector
    823  * \return true - success, vectors are linear independent, false - failure due to linear dependency
    824  */
    825 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2, const Vector * const y3)
    826 {
    827   Vector x1, x2;
    828 
    829   x1.CopyVector(y1);
    830   x1.SubtractVector(y2);
    831   x2.CopyVector(y3);
    832   x2.SubtractVector(y2);
    833   if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    834     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
    835     return false;
    836   }
    837 //  Log() << Verbose(4) << "relative, first plane coordinates:";
    838 //  x1.Output((ofstream *)&cout);
    839 //  Log() << Verbose(0) << endl;
    840 //  Log() << Verbose(4) << "second plane coordinates:";
    841 //  x2.Output((ofstream *)&cout);
    842 //  Log() << Verbose(0) << endl;
    843 
    844   this->x[0] = (x1.x[1]*x2.x[2] - x1.x[2]*x2.x[1]);
    845   this->x[1] = (x1.x[2]*x2.x[0] - x1.x[0]*x2.x[2]);
    846   this->x[2] = (x1.x[0]*x2.x[1] - x1.x[1]*x2.x[0]);
    847   Normalize();
    848 
    849   return true;
    850 };
    851 
    852 
    853 /** Calculates orthonormal vector to two given vectors.
    854  * Makes this vector orthonormal to two given vectors. This is very similar to the other
    855  * vector::MakeNormalVector(), only there three points whereas here two difference
    856  * vectors are given.
    857  * \param *x1 first vector
    858  * \param *x2 second vector
    859  * \return true - success, vectors are linear independent, false - failure due to linear dependency
    860  */
    861 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2)
    862 {
    863   Vector x1,x2;
    864   x1.CopyVector(y1);
    865   x2.CopyVector(y2);
    866   Zero();
    867   if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    868     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
    869     return false;
    870   }
    871 //  Log() << Verbose(4) << "relative, first plane coordinates:";
    872 //  x1.Output((ofstream *)&cout);
    873 //  Log() << Verbose(0) << endl;
    874 //  Log() << Verbose(4) << "second plane coordinates:";
    875 //  x2.Output((ofstream *)&cout);
    876 //  Log() << Verbose(0) << endl;
    877 
    878   this->x[0] = (x1.x[1]*x2.x[2] - x1.x[2]*x2.x[1]);
    879   this->x[1] = (x1.x[2]*x2.x[0] - x1.x[0]*x2.x[2]);
    880   this->x[2] = (x1.x[0]*x2.x[1] - x1.x[1]*x2.x[0]);
    881   Normalize();
    882 
    883   return true;
    884 };
    885 
    886 /** Calculates orthonormal vector to one given vectors.
     657};
     658
     659
     660/** Calculates orthonormal vector to one given vector.
    887661 * Just subtracts the projection onto the given vector from this vector.
    888662 * The removed part of the vector is Vector::Projection()
     
    890664 * \return true - success, false - vector is zero
    891665 */
    892 bool Vector::MakeNormalVector(const Vector * const y1)
     666bool Vector::MakeNormalTo(const Vector &y1)
    893667{
    894668  bool result = false;
    895   double factor = y1->ScalarProduct(this)/y1->NormSquared();
     669  double factor = y1.ScalarProduct(this)/y1.NormSquared();
    896670  Vector x1;
    897   x1.CopyVector(y1);
     671  x1.CopyVector(&y1);
    898672  x1.Scale(factor);
    899673  SubtractVector(&x1);
     
    917691  double norm;
    918692
    919   Log() << Verbose(4);
    920   GivenVector->Output();
    921   Log() << Verbose(0) << endl;
    922693  for (j=NDIM;j--;)
    923694    Components[j] = -1;
     
    926697    if (fabs(GivenVector->x[j]) > MYEPSILON)
    927698      Components[Last++] = j;
    928   Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
    929699
    930700  switch(Last) {
     
    966736};
    967737
    968 /** Creates a new vector as the one with least square distance to a given set of \a vectors.
    969  * \param *vectors set of vectors
    970  * \param num number of vectors
    971  * \return true if success, false if failed due to linear dependency
    972  */
    973 bool Vector::LSQdistance(const Vector **vectors, int num)
    974 {
    975   int j;
    976 
    977   for (j=0;j<num;j++) {
    978     Log() << Verbose(1) << j << "th atom's vector: ";
    979     (vectors[j])->Output();
    980     Log() << Verbose(0) << endl;
    981   }
    982 
    983   int np = 3;
    984   struct LSQ_params par;
    985 
    986    const gsl_multimin_fminimizer_type *T =
    987      gsl_multimin_fminimizer_nmsimplex;
    988    gsl_multimin_fminimizer *s = NULL;
    989    gsl_vector *ss, *y;
    990    gsl_multimin_function minex_func;
    991 
    992    size_t iter = 0, i;
    993    int status;
    994    double size;
    995 
    996    /* Initial vertex size vector */
    997    ss = gsl_vector_alloc (np);
    998    y = gsl_vector_alloc (np);
    999 
    1000    /* Set all step sizes to 1 */
    1001    gsl_vector_set_all (ss, 1.0);
    1002 
    1003    /* Starting point */
    1004    par.vectors = vectors;
    1005    par.num = num;
    1006 
    1007    for (i=NDIM;i--;)
    1008     gsl_vector_set(y, i, (vectors[0]->x[i] - vectors[1]->x[i])/2.);
    1009 
    1010    /* Initialize method and iterate */
    1011    minex_func.f = &LSQ;
    1012    minex_func.n = np;
    1013    minex_func.params = (void *)&par;
    1014 
    1015    s = gsl_multimin_fminimizer_alloc (T, np);
    1016    gsl_multimin_fminimizer_set (s, &minex_func, y, ss);
    1017 
    1018    do
    1019      {
    1020        iter++;
    1021        status = gsl_multimin_fminimizer_iterate(s);
    1022 
    1023        if (status)
    1024          break;
    1025 
    1026        size = gsl_multimin_fminimizer_size (s);
    1027        status = gsl_multimin_test_size (size, 1e-2);
    1028 
    1029        if (status == GSL_SUCCESS)
    1030          {
    1031            printf ("converged to minimum at\n");
    1032          }
    1033 
    1034        printf ("%5d ", (int)iter);
    1035        for (i = 0; i < (size_t)np; i++)
    1036          {
    1037            printf ("%10.3e ", gsl_vector_get (s->x, i));
    1038          }
    1039        printf ("f() = %7.3f size = %.3f\n", s->fval, size);
    1040      }
    1041    while (status == GSL_CONTINUE && iter < 100);
    1042 
    1043   for (i=(size_t)np;i--;)
    1044     this->x[i] = gsl_vector_get(s->x, i);
    1045    gsl_vector_free(y);
    1046    gsl_vector_free(ss);
    1047    gsl_multimin_fminimizer_free (s);
    1048 
    1049   return true;
    1050 };
    1051738
    1052739/** Adds vector \a *y componentwise.
     
    1092779}
    1093780
    1094 
    1095 /** Asks for position, checks for boundary.
    1096  * \param cell_size unitary size of cubic cell, coordinates must be within 0...cell_size
    1097  * \param check whether bounds shall be checked (true) or not (false)
    1098  */
    1099 void Vector::AskPosition(const double * const cell_size, const bool check)
    1100 {
    1101   char coords[3] = {'x','y','z'};
    1102   int j = -1;
    1103   for (int i=0;i<3;i++) {
    1104     j += i+1;
    1105     do {
    1106       Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
    1107       cin >> x[i];
    1108     } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
    1109   }
    1110 };
    1111 
     781// this function is completely unused so it is deactivated until new uses arrive and a new
     782// place can be found
     783#if 0
    1112784/** Solves a vectorial system consisting of two orthogonal statements and a norm statement.
    1113785 * This is linear system of equations to be solved, however of the three given (skp of this vector\
     
    1281953};
    1282954
     955#endif
     956
    1283957/**
    1284958 * Checks whether this vector is within the parallelepiped defined by the given three vectors and
  • src/vector.hpp

    rf9352d r0a4f7f  
    2424class Vector {
    2525  public:
    26     double x[NDIM];
    2726
    2827  Vector();
    2928  Vector(const double x1, const double x2, const double x3);
     29  Vector(const Vector& src);
    3030  ~Vector();
    3131
     
    4848  void CopyVector(const Vector * const y);
    4949  void CopyVector(const Vector &y);
    50   void RotateVector(const Vector * const y, const double alpha);
    5150  void VectorProduct(const Vector * const y);
    5251  void ProjectOntoPlane(const Vector * const y);
     
    6362  void Scale(const double factor);
    6463  void MatrixMultiplication(const double * const M);
    65   void InverseMatrixMultiplication(const double * const M);
     64  bool InverseMatrixMultiplication(const double * const M);
    6665  void KeepPeriodic(const double * const matrix);
    6766  void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors);
    6867  double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const;
    69   bool GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector);
    70   bool GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *Normal = NULL);
    7168  bool GetOneNormalVector(const Vector * const x1);
    72   bool MakeNormalVector(const Vector * const y1);
    73   bool MakeNormalVector(const Vector * const y1, const Vector * const y2);
    74   bool MakeNormalVector(const Vector * const x1, const Vector * const x2, const Vector * const x3);
    75   bool SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c);
    76   bool LSQdistance(const Vector ** vectors, int dim);
    77   void AskPosition(const double * const cell_size, const bool check);
    78   void Output() const;
     69  bool MakeNormalTo(const Vector &y1);
     70  //bool SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c);
    7971  bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;
    8072  void WrapPeriodically(const double * const M, const double * const Minv);
     73
     74  // Accessors ussually come in pairs... and sometimes even more than that
     75  double& operator[](size_t i);
     76  const double& operator[](size_t i) const;
     77  double& at(size_t i);
     78  const double& at(size_t i) const;
     79
     80  // Assignment operator
     81  Vector &operator=(const Vector& src);
     82
     83  // Access to internal structure
     84  double* get();
     85
     86private:
     87  double x[NDIM];
    8188
    8289};
Note: See TracChangeset for help on using the changeset viewer.