Changeset e9b8bb
- Timestamp:
- Aug 6, 2008, 9:02:01 AM (16 years ago)
- 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, 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:
- 5e0d1f
- Parents:
- d7e30c
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
rd7e30c re9b8bb 151 151 }; 152 152 153 void BoundaryTriangleSet::GetNormalVector( vector &NormalVector)153 void BoundaryTriangleSet::GetNormalVector(Vector &NormalVector) 154 154 { 155 155 // get normal vector … … 211 211 Boundaries *BoundaryPoints = new Boundaries [NDIM]; // first is alpha, second is (r, nr) 212 212 BoundariesTestPair BoundaryTestPair; 213 vector AxisVector, AngleReferenceVector, AngleReferenceNormalVector;213 Vector AxisVector, AngleReferenceVector, AngleReferenceNormalVector; 214 214 double radius, angle; 215 215 // 3a. Go through every axis … … 233 233 while (Walker->next != mol->end) { 234 234 Walker = Walker->next; 235 vector ProjectedVector;235 Vector ProjectedVector; 236 236 ProjectedVector.CopyVector(&Walker->x); 237 237 ProjectedVector.ProjectOntoPlane(&AxisVector); … … 316 316 // construct the vector of each side of the triangle on the projected plane (defined by normal vector AxisVector) 317 317 { 318 vector SideA, SideB, SideC, SideH;318 Vector SideA, SideB, SideC, SideH; 319 319 SideA.CopyVector(&left->second.second->x); 320 320 SideA.ProjectOntoPlane(&AxisVector); … … 394 394 GreatestDiameter[i] = 0.; 395 395 double OldComponent, tmp, w1, w2; 396 vector DistanceVector, OtherVector;396 Vector DistanceVector, OtherVector; 397 397 int component, Othercomponent; 398 398 for(int axis=0;axis<NDIM;axis++) { // regard each projected plane … … 470 470 double PyramidVolume = 0.; 471 471 double G,h; 472 vector x,y;472 Vector x,y; 473 473 double a,b,c; 474 474 475 475 // 1. calculate center of gravity 476 476 *out << endl; 477 vector *CenterOfGravity = mol->DetermineCenterOfGravity(out);477 Vector *CenterOfGravity = mol->DetermineCenterOfGravity(out); 478 478 479 479 // 2. translate all points into CoG … … 578 578 clustervolume = ClusterVolume; 579 579 double *GreatestDiameter = GetDiametersOfCluster(out, BoundaryPoints, mol, IsAngstroem); 580 vector BoxLengths;580 Vector BoxLengths; 581 581 int repetition[NDIM] = {1, 1, 1}; 582 582 int TotalNoClusters = 1; … … 755 755 class BoundaryPointSet *peak = NULL; 756 756 double SmallestAngle, TempAngle; 757 vector NormalVector, VirtualNormalVector, CenterVector, TempVector, PropagationVector;757 Vector NormalVector, VirtualNormalVector, CenterVector, TempVector, PropagationVector; 758 758 LineMap::iterator LineChecker[2]; 759 759 do { -
src/boundary.hpp
rd7e30c re9b8bb 88 88 ~BoundaryTriangleSet(); 89 89 90 void GetNormalVector( vector &NormalVector);90 void GetNormalVector(Vector &NormalVector); 91 91 92 92 class BoundaryPointSet *endpoints[3]; -
src/builder.cpp
rd7e30c re9b8bb 63 63 { 64 64 atom *first, *second, *third, *fourth; 65 vector **atoms;66 vector x,y,z,n; // coordinates for absolute point in cell volume65 Vector **atoms; 66 Vector x,y,z,n; // coordinates for absolute point in cell volume 67 67 double a,b,c; 68 68 char choice; // menu choice char … … 99 99 cout << Verbose(0) << "Enter relative coordinates." << endl; 100 100 first->x.AskPosition(mol->cell_size, false); 101 first->x.AddVector((const vector *)&x);101 first->x.AddVector((const Vector *)&x); 102 102 cout << Verbose(0) << "\n"; 103 } while (!(valid = mol->CheckBounds((const vector *)&first->x)));103 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 104 104 first->type = periode->AskElement(); // give type 105 105 mol->AddAtom(first); // add to molecule … … 117 117 first->x.x[i] += second->x.x[i]; 118 118 } 119 } while (!(valid = mol->CheckBounds((const vector *)&first->x)));119 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 120 120 first->type = periode->AskElement(); // give type 121 121 mol->AddAtom(first); // add to molecule … … 219 219 first->x.Output((ofstream *)&cout); 220 220 cout << Verbose(0) << endl; 221 } while (!(valid = mol->CheckBounds((const vector *)&first->x)));221 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 222 222 first->type = periode->AskElement(); // give type 223 223 mol->AddAtom(first); // add to molecule … … 226 226 case 'e': // least square distance position to a set of atoms 227 227 first = new atom; 228 atoms = new ( vector*[128]);228 atoms = new (Vector*[128]); 229 229 valid = true; 230 230 for(int i=128;i--;) … … 259 259 static void CenterAtoms(molecule *mol) 260 260 { 261 vector x, y;261 Vector x, y; 262 262 char choice; // menu choice char 263 263 … … 315 315 { 316 316 atom *first, *second, *third; 317 vector x,n;317 Vector x,n; 318 318 char choice; // menu choice char 319 319 … … 335 335 third = mol->AskAtom("Enter third atom: "); 336 336 337 n.MakeNormalVector((const vector *)&first->x,(const vector *)&second->x,(const vector *)&third->x);337 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x); 338 338 break; 339 339 case 'b': // normal vector of mirror plane … … 346 346 second = mol->AskAtom("Enter second atom: "); 347 347 348 n.CopyVector((const vector *)&first->x);349 n.SubtractVector((const vector *)&second->x);348 n.CopyVector((const Vector *)&first->x); 349 n.SubtractVector((const Vector *)&second->x); 350 350 n.Normalize(); 351 351 break; 352 352 case 'd': 353 353 char shorthand[4]; 354 vector a;354 Vector a; 355 355 struct lsq_params param; 356 356 do { … … 383 383 { 384 384 atom *first, *second, *third; 385 vector n;385 Vector n; 386 386 char choice; // menu choice char 387 387 … … 402 402 third = mol->AskAtom("Enter third atom: "); 403 403 404 n.MakeNormalVector((const vector *)&first->x,(const vector *)&second->x,(const vector *)&third->x);404 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x); 405 405 break; 406 406 case 'b': // normal vector of mirror plane … … 413 413 second = mol->AskAtom("Enter second atom: "); 414 414 415 n.CopyVector((const vector *)&first->x);416 n.SubtractVector((const vector *)&second->x);415 n.CopyVector((const Vector *)&first->x); 416 n.SubtractVector((const Vector *)&second->x); 417 417 n.Normalize(); 418 418 break; … … 421 421 n.Output((ofstream *)&cout); 422 422 cout << Verbose(0) << endl; 423 mol->Mirror((const vector *)&n);423 mol->Mirror((const Vector *)&n); 424 424 }; 425 425 … … 458 458 while(first->next != mol->end) { 459 459 first = first->next; 460 if (first->x.Distance((const vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...460 if (first->x.Distance((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ... 461 461 mol->RemoveAtom(first); 462 462 } … … 488 488 { 489 489 atom *first, *second, *third; 490 vector x,y;490 Vector x,y; 491 491 double min[256], tmp1, tmp2, tmp3; 492 492 int Z; … … 519 519 tmp1 = 0.; 520 520 if (first != second) { 521 x.CopyVector((const vector *)&first->x);522 x.SubtractVector((const vector *)&second->x);521 x.CopyVector((const Vector *)&first->x); 522 x.SubtractVector((const Vector *)&second->x); 523 523 tmp1 = x.Norm(); 524 524 } … … 535 535 for (int i=NDIM;i--;) 536 536 min[i] = 0.; 537 x.CopyVector((const vector *)&first->x);538 x.SubtractVector((const vector *)&second->x);537 x.CopyVector((const Vector *)&first->x); 538 x.SubtractVector((const Vector *)&second->x); 539 539 tmp1 = x.Norm(); 540 540 cout << Verbose(1) << "Distance vector is "; … … 549 549 third = mol->AskAtom("Enter last atom: "); 550 550 tmp1 = tmp2 = tmp3 = 0.; 551 x.CopyVector((const vector *)&first->x);552 x.SubtractVector((const vector *)&second->x);553 y.CopyVector((const vector *)&third->x);554 y.SubtractVector((const vector *)&second->x);551 x.CopyVector((const Vector *)&first->x); 552 x.SubtractVector((const Vector *)&second->x); 553 y.CopyVector((const Vector *)&third->x); 554 y.SubtractVector((const Vector *)&second->x); 555 555 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 556 cout << Verbose(0) << (acos(x.ScalarProduct((const vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;556 cout << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl; 557 557 break; 558 558 case 'd': … … 727 727 static int ParseCommandLineOptions(int argc, char **argv, molecule *&mol, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&PathToDatabases) 728 728 { 729 vector x,y,z,n; // coordinates for absolute point in cell volume729 Vector x,y,z,n; // coordinates for absolute point in cell volume 730 730 double *factor; // unit factor if desired 731 731 ifstream test; … … 889 889 for (int i=NDIM;i--;) 890 890 x.x[i] = atof(argv[argptr+i]); 891 mol->Translate((const vector *)&x);891 mol->Translate((const Vector *)&x); 892 892 argptr+=3; 893 893 break; … … 958 958 mol->cell_size[j] += x.x[i]*2.; 959 959 } 960 mol->Translate((const vector *)&x);960 mol->Translate((const Vector *)&x); 961 961 break; 962 962 case 'O': … … 1034 1034 int count; 1035 1035 element ** Elements; 1036 vector ** vectors;1036 Vector ** vectors; 1037 1037 if (faktor < 1) { 1038 1038 cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl; … … 1043 1043 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1044 1044 Elements = new element *[count]; 1045 vectors = new vector *[count];1045 vectors = new Vector *[count]; 1046 1046 j = 0; 1047 1047 first = mol->start; … … 1117 1117 atom *first, *second; 1118 1118 char choice; // menu choice char 1119 vector x,y,z,n; // coordinates for absolute point in cell volume1119 Vector x,y,z,n; // coordinates for absolute point in cell volume 1120 1120 double *factor; // unit factor if desired 1121 1121 bool valid; // flag if input was valid or not … … 1132 1132 clock_t start,end; 1133 1133 element **Elements; 1134 vector **vectors;1134 Vector **vectors; 1135 1135 1136 1136 // =========================== PARSE COMMAND LINE OPTIONS ==================================== … … 1231 1231 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 1232 1232 Elements = new element *[count]; 1233 vectors = new vector *[count];1233 vectors = new Vector *[count]; 1234 1234 j = 0; 1235 1235 first = mol->start; … … 1335 1335 cout << Verbose(0) << "Enter translation vector." << endl; 1336 1336 x.AskPosition(mol->cell_size,0); 1337 mol->Translate((const vector *)&x);1337 mol->Translate((const Vector *)&x); 1338 1338 break; 1339 1339 -
src/moleculelist.cpp
rd7e30c re9b8bb 388 388 bool intermediateResult = true; 389 389 atom *Walker = NULL; 390 vector BoxDimension;390 Vector BoxDimension; 391 391 char *FragmentNumber = NULL; 392 392 char *path = NULL; -
src/molecules.cpp
rd7e30c re9b8bb 18 18 double sum = 0.; 19 19 struct LSQ_params *par = (struct LSQ_params *)params; 20 vector **vectors = par->vectors;20 Vector **vectors = par->vectors; 21 21 int num = par->num; 22 22 … … 180 180 atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added 181 181 double b,l,d,f,g, alpha, factors[NDIM]; // hold temporary values in triple bond case for coordination determination 182 vector Orthovector1, Orthovector2; // temporary vectors in coordination construction183 vector InBondvector; // vector in direction of *Bond182 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 183 Vector InBondvector; // vector in direction of *Bond 184 184 bond *Binder = NULL; 185 185 double *matrix; … … 587 587 * \param *dim vector class 588 588 */ 589 void molecule::SetBoxDimension( vector *dim)589 void molecule::SetBoxDimension(Vector *dim) 590 590 { 591 591 cell_size[0] = dim->x[0]; … … 601 601 * \param *BoxLengths box lengths 602 602 */ 603 bool molecule::CenterInBox(ofstream *out, vector *BoxLengths)603 bool molecule::CenterInBox(ofstream *out, Vector *BoxLengths) 604 604 { 605 605 bool status = true; 606 606 atom *ptr = NULL; 607 vector *min = new vector;608 vector *max = new vector;607 Vector *min = new Vector; 608 Vector *max = new Vector; 609 609 610 610 // gather min and max for each axis … … 651 651 * \param *max coordinates of other edge, specifying box dimensions. 652 652 */ 653 void molecule::CenterEdge(ofstream *out, vector *max)654 { 655 vector *min = new vector;653 void molecule::CenterEdge(ofstream *out, Vector *max) 654 { 655 Vector *min = new Vector; 656 656 657 657 // *out << Verbose(3) << "Begin of CenterEdge." << endl; … … 690 690 * \param *center return vector for translation vector 691 691 */ 692 void molecule::CenterOrigin(ofstream *out, vector *center)692 void molecule::CenterOrigin(ofstream *out, Vector *center) 693 693 { 694 694 int Num = 0; … … 713 713 * \return pointer to center of gravity vector 714 714 */ 715 vector * molecule::DetermineCenterOfGravity(ofstream *out)715 Vector * molecule::DetermineCenterOfGravity(ofstream *out) 716 716 { 717 717 atom *ptr = start->next; // start at first in list 718 vector *a = new vector();719 vector tmp;718 Vector *a = new Vector(); 719 Vector tmp; 720 720 double Num = 0; 721 721 … … 742 742 * \param *center return vector for translation vector 743 743 */ 744 void molecule::CenterGravity(ofstream *out, vector *center)744 void molecule::CenterGravity(ofstream *out, Vector *center) 745 745 { 746 746 if (center == NULL) { … … 769 769 * \param trans[] translation vector. 770 770 */ 771 void molecule::Translate(const vector *trans)771 void molecule::Translate(const Vector *trans) 772 772 { 773 773 atom *ptr = start; … … 782 782 * \param n[] normal vector of mirror plane. 783 783 */ 784 void molecule::Mirror(const vector *n)784 void molecule::Mirror(const Vector *n) 785 785 { 786 786 atom *ptr = start; … … 795 795 * \param Center reference to return vector 796 796 */ 797 void molecule::DetermineCenter( vector &Center)797 void molecule::DetermineCenter(Vector &Center) 798 798 { 799 799 atom *Walker = start; … … 802 802 double tmp; 803 803 bool flag; 804 vector Testvector, Translationvector;804 Vector Testvector, Translationvector; 805 805 806 806 do { … … 867 867 atom *ptr = start; // start at first in list 868 868 double InertiaTensor[NDIM*NDIM]; 869 vector *CenterOfGravity = DetermineCenterOfGravity(out);869 Vector *CenterOfGravity = DetermineCenterOfGravity(out); 870 870 871 871 CenterGravity(out, CenterOfGravity); … … 878 878 while (ptr->next != end) { 879 879 ptr = ptr->next; 880 vector x;880 Vector x; 881 881 x.CopyVector(&ptr->x); 882 882 //x.SubtractVector(CenterOfGravity); … … 934 934 while (ptr->next != end) { 935 935 ptr = ptr->next; 936 vector x;936 Vector x; 937 937 x.CopyVector(&ptr->x); 938 938 //x.SubtractVector(CenterOfGravity); … … 1060 1060 * \param n[] alignment vector. 1061 1061 */ 1062 void molecule::Align( vector *n)1062 void molecule::Align(Vector *n) 1063 1063 { 1064 1064 atom *ptr = start; 1065 1065 double alpha, tmp; 1066 vector z_axis;1066 Vector z_axis; 1067 1067 z_axis.x[0] = 0.; 1068 1068 z_axis.x[1] = 0.; … … 1168 1168 * \return true - is within, false - out of cell 1169 1169 */ 1170 bool molecule::CheckBounds(const vector *x) const1170 bool molecule::CheckBounds(const Vector *x) const 1171 1171 { 1172 1172 bool result = true; … … 1188 1188 { 1189 1189 double res = 0, t; 1190 vector a,b,c,d;1190 Vector a,b,c,d; 1191 1191 struct lsq_params *par = (struct lsq_params *)params; 1192 1192 atom *ptr = par->mol->start; … … 1209 1209 d.Scale(&t); 1210 1210 c.SubtractVector(&d); // ... yielding distance vector 1211 res += d.ScalarProduct((const vector *)&d); // add squared distance1211 res += d.ScalarProduct((const Vector *)&d); // add squared distance 1212 1212 } 1213 1213 } … … 1542 1542 double distance, MinDistance, MaxDistance; 1543 1543 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1544 vector x;1544 Vector x; 1545 1545 1546 1546 BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem); … … 3925 3925 enum Shading *ColorList = NULL; 3926 3926 double tmp; 3927 vector Translationvector;3927 Vector Translationvector; 3928 3928 //class StackClass<atom *> *CompStack = NULL; 3929 3929 class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount); … … 4326 4326 int flag; 4327 4327 double *Distances = NULL, *OtherDistances = NULL; 4328 vector CenterOfGravity, OtherCenterOfGravity;4328 Vector CenterOfGravity, OtherCenterOfGravity; 4329 4329 size_t *PermMap = NULL, *OtherPermMap = NULL; 4330 4330 int *PermutationMap = NULL; -
src/molecules.hpp
rd7e30c re9b8bb 73 73 */ 74 74 struct LSQ_params { 75 vector **vectors;75 Vector **vectors; 76 76 int num; 77 77 }; … … 94 94 class atom { 95 95 public: 96 vector x; //!< coordinate array of atom, giving position within cell97 vector v; //!< velocity array of atom96 Vector x; //!< coordinate array of atom, giving position within cell 97 Vector v; //!< velocity array of atom 98 98 element *type; //!< pointing to element 99 99 atom *previous; //!< previous atom in molecule list … … 212 212 void CountElements(); 213 213 void CalculateOrbitals(class config &configuration); 214 bool CenterInBox(ofstream *out, vector *BoxLengths);215 void CenterEdge(ofstream *out, vector *max);216 void CenterOrigin(ofstream *out, vector *max);217 void CenterGravity(ofstream *out, vector *max);218 void Translate(const vector *x);219 void Mirror(const vector *x);220 void Align( vector *n);214 bool CenterInBox(ofstream *out, Vector *BoxLengths); 215 void CenterEdge(ofstream *out, Vector *max); 216 void CenterOrigin(ofstream *out, Vector *max); 217 void CenterGravity(ofstream *out, Vector *max); 218 void Translate(const Vector *x); 219 void Mirror(const Vector *x); 220 void Align(Vector *n); 221 221 void Scale(double **factor); 222 void DetermineCenter( vector ¢er);223 vector * DetermineCenterOfGravity(ofstream *out);224 void SetBoxDimension( vector *dim);222 void DetermineCenter(Vector ¢er); 223 Vector * DetermineCenterOfGravity(ofstream *out); 224 void SetBoxDimension(Vector *dim); 225 225 double * ReturnFullMatrixforSymmetric(double *cell_size); 226 226 void ScanForPeriodicCorrection(ofstream *out); … … 229 229 bool VerletForceIntegration(char *file, double delta_t); 230 230 231 bool CheckBounds(const vector *x) const;231 bool CheckBounds(const Vector *x) const; 232 232 void GetAlignvector(struct lsq_params * par) const; 233 233 -
src/vector.cpp
rd7e30c re9b8bb 12 12 /** Constructor of class vector. 13 13 */ 14 vector::vector() { x[0] = x[1] = x[2] = 0.; };14 Vector::Vector() { x[0] = x[1] = x[2] = 0.; }; 15 15 16 16 /** Constructor of class vector. 17 17 */ 18 vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };18 Vector::Vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; }; 19 19 20 20 /** Desctructor of class vector. 21 21 */ 22 vector::~vector() {};22 Vector::~Vector() {}; 23 23 24 24 /** Calculates distance between this and another vector. … … 26 26 * \return \f$| x - y |^2\f$ 27 27 */ 28 double vector::Distance(const vector *y) const28 double Vector::Distance(const Vector *y) const 29 29 { 30 30 double res = 0.; … … 39 39 * \return \f$| x - y |^2\f$ 40 40 */ 41 double vector::PeriodicDistance(const vector *y, const double *cell_size) const41 double Vector::PeriodicDistance(const Vector *y, const double *cell_size) const 42 42 { 43 43 double res = Distance(y), tmp, matrix[NDIM*NDIM]; 44 vector Shiftedy, TranslationVector;44 Vector Shiftedy, TranslationVector; 45 45 int N[NDIM]; 46 46 matrix[0] = cell_size[0]; … … 76 76 * Tries to translate a vector into each adjacent neighbouring cell. 77 77 */ 78 void vector::KeepPeriodic(ofstream *out, double *matrix)78 void Vector::KeepPeriodic(ofstream *out, double *matrix) 79 79 { 80 80 // int N[NDIM]; 81 81 // bool flag = false; 82 82 //vector Shifted, TranslationVector; 83 vector TestVector;83 Vector TestVector; 84 84 // *out << Verbose(1) << "Begin of KeepPeriodic." << endl; 85 85 // *out << Verbose(2) << "Vector is: "; … … 107 107 * \return \f$\langle x, y \rangle\f$ 108 108 */ 109 double vector::ScalarProduct(const vector *y) const109 double Vector::ScalarProduct(const Vector *y) const 110 110 { 111 111 double res = 0.; … … 119 119 * \return \f$\langle x, y \rangle\f$ 120 120 */ 121 void vector::ProjectOntoPlane(const vector *y)122 { 123 vector tmp;121 void Vector::ProjectOntoPlane(const Vector *y) 122 { 123 Vector tmp; 124 124 tmp.CopyVector(y); 125 125 tmp.Scale(Projection(y)); … … 131 131 * \return \f$\langle x, y \rangle\f$ 132 132 */ 133 double vector::Projection(const vector *y) const133 double Vector::Projection(const Vector *y) const 134 134 { 135 135 return (ScalarProduct(y)); … … 139 139 * \return \f$|x|\f$ 140 140 */ 141 double vector::Norm() const141 double Vector::Norm() const 142 142 { 143 143 double res = 0.; … … 149 149 /** Normalizes this vector. 150 150 */ 151 void vector::Normalize()151 void Vector::Normalize() 152 152 { 153 153 double res = 0.; … … 160 160 /** Zeros all components of this vector. 161 161 */ 162 void vector::Zero()162 void Vector::Zero() 163 163 { 164 164 for (int i=NDIM;i--;) … … 168 168 /** Zeros all components of this vector. 169 169 */ 170 void vector::One(double one)170 void Vector::One(double one) 171 171 { 172 172 for (int i=NDIM;i--;) … … 176 176 /** Initialises all components of this vector. 177 177 */ 178 void vector::Init(double x1, double x2, double x3)178 void Vector::Init(double x1, double x2, double x3) 179 179 { 180 180 x[0] = x1; … … 187 187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 188 188 */ 189 double vector::Angle(vector *y) const189 double Vector::Angle(Vector *y) const 190 190 { 191 191 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); … … 196 196 * \param alpha rotation angle in radian 197 197 */ 198 void vector::RotateVector(const vector *axis, const double alpha)199 { 200 vector a,y;198 void Vector::RotateVector(const Vector *axis, const double alpha) 199 { 200 Vector a,y; 201 201 // normalise this vector with respect to axis 202 202 a.CopyVector(this); … … 220 220 * \return lhs + a 221 221 */ 222 vector& operator+=(vector& a, const vector& b)222 Vector& operator+=(Vector& a, const Vector& b) 223 223 { 224 224 a.AddVector(&b); … … 230 230 * \return lhs.x[i] * m 231 231 */ 232 vector& operator*=(vector& a, const double m)232 Vector& operator*=(Vector& a, const double m) 233 233 { 234 234 a.Scale(m); … … 241 241 * \return a + b 242 242 */ 243 vector& operator+(const vector& a, const vector& b)244 { 245 vector *x = new vector;243 Vector& operator+(const Vector& a, const Vector& b) 244 { 245 Vector *x = new Vector; 246 246 x->CopyVector(&a); 247 247 x->AddVector(&b); … … 254 254 * \return a + b 255 255 */ 256 vector& operator*(const vector& a, const double m)257 { 258 vector *x = new vector;256 Vector& operator*(const Vector& a, const double m) 257 { 258 Vector *x = new Vector; 259 259 x->CopyVector(&a); 260 260 x->Scale(m); … … 266 266 * \param *out output stream 267 267 */ 268 bool vector::Output(ofstream *out) const268 bool Vector::Output(ofstream *out) const 269 269 { 270 270 if (out != NULL) { … … 281 281 }; 282 282 283 ofstream& operator<<(ofstream& ost, vector& m)283 ofstream& operator<<(ofstream& ost,Vector& m) 284 284 { 285 285 m.Output(&ost); … … 290 290 * \param *factor pointer to scaling factor 291 291 */ 292 void vector::Scale(double **factor)292 void Vector::Scale(double **factor) 293 293 { 294 294 for (int i=NDIM;i--;) … … 296 296 }; 297 297 298 void vector::Scale(double *factor)298 void Vector::Scale(double *factor) 299 299 { 300 300 for (int i=NDIM;i--;) … … 302 302 }; 303 303 304 void vector::Scale(double factor)304 void Vector::Scale(double factor) 305 305 { 306 306 for (int i=NDIM;i--;) … … 311 311 * \param trans[] translation vector. 312 312 */ 313 void vector::Translate(const vector *trans)313 void Vector::Translate(const Vector *trans) 314 314 { 315 315 for (int i=NDIM;i--;) … … 320 320 * \param *matrix NDIM_NDIM array 321 321 */ 322 void vector::MatrixMultiplication(double *M)323 { 324 vector C;322 void Vector::MatrixMultiplication(double *M) 323 { 324 Vector C; 325 325 // do the matrix multiplication 326 326 C.x[0] = M[0]*x[0]+M[3]*x[1]+M[6]*x[2]; … … 335 335 * \param *matrix NDIM_NDIM array 336 336 */ 337 void vector::InverseMatrixMultiplication(double *A)338 { 339 vector C;337 void Vector::InverseMatrixMultiplication(double *A) 338 { 339 Vector C; 340 340 double B[NDIM*NDIM]; 341 341 double detA = RDET3(A); … … 375 375 * \param *factors three-component vector with the factor for each given vector 376 376 */ 377 void vector::LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors)377 void Vector::LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors) 378 378 { 379 379 for(int i=NDIM;i--;) … … 384 384 * \param n[] normal vector of mirror plane. 385 385 */ 386 void vector::Mirror(const vector *n)386 void Vector::Mirror(const Vector *n) 387 387 { 388 388 double projection; … … 406 406 * \return true - success, vectors are linear independent, false - failure due to linear dependency 407 407 */ 408 bool vector::MakeNormalVector(const vector *y1, const vector *y2, const vector *y3)409 { 410 vector x1, x2;408 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2, const Vector *y3) 409 { 410 Vector x1, x2; 411 411 412 412 x1.CopyVector(y1); … … 442 442 * \return true - success, vectors are linear independent, false - failure due to linear dependency 443 443 */ 444 bool vector::MakeNormalVector(const vector *y1, const vector *y2)445 { 446 vector x1,x2;444 bool Vector::MakeNormalVector(const Vector *y1, const Vector *y2) 445 { 446 Vector x1,x2; 447 447 x1.CopyVector(y1); 448 448 x2.CopyVector(y2); … … 472 472 * \return true - success, false - vector is zero 473 473 */ 474 bool vector::MakeNormalVector(const vector *y1)474 bool Vector::MakeNormalVector(const Vector *y1) 475 475 { 476 476 bool result = false; 477 vector x1;477 Vector x1; 478 478 x1.CopyVector(y1); 479 479 x1.Scale(x1.Projection(this)); … … 491 491 * \return true - success, false - failure (null vector given) 492 492 */ 493 bool vector::GetOneNormalVector(const vector *GivenVector)493 bool Vector::GetOneNormalVector(const Vector *GivenVector) 494 494 { 495 495 int Components[NDIM]; // contains indices of non-zero components … … 537 537 * \return scaling parameter for this vector 538 538 */ 539 double vector::CutsPlaneAt(vector *A, vector *B, vector *C)539 double Vector::CutsPlaneAt(Vector *A, Vector *B, Vector *C) 540 540 { 541 541 // cout << Verbose(3) << "For comparison: "; … … 552 552 * \return true if success, false if failed due to linear dependency 553 553 */ 554 bool vector::LSQdistance(vector **vectors, int num)554 bool Vector::LSQdistance(Vector **vectors, int num) 555 555 { 556 556 int j; … … 634 634 * \param *y vector 635 635 */ 636 void vector::AddVector(const vector *y)636 void Vector::AddVector(const Vector *y) 637 637 { 638 638 for (int i=NDIM;i--;) … … 643 643 * \param *y vector 644 644 */ 645 void vector::SubtractVector(const vector *y)645 void Vector::SubtractVector(const Vector *y) 646 646 { 647 647 for (int i=NDIM;i--;) … … 652 652 * \param *y vector 653 653 */ 654 void vector::CopyVector(const vector *y)654 void Vector::CopyVector(const Vector *y) 655 655 { 656 656 for (int i=NDIM;i--;) … … 663 663 * \param check whether bounds shall be checked (true) or not (false) 664 664 */ 665 void vector::AskPosition(double *cell_size, bool check)665 void Vector::AskPosition(double *cell_size, bool check) 666 666 { 667 667 char coords[3] = {'x','y','z'}; … … 691 691 * \bug this is not yet working properly 692 692 */ 693 bool vector::SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c)693 bool Vector::SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c) 694 694 { 695 695 double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C; -
src/vector.hpp
rd7e30c re9b8bb 2 2 #define VECTOR_HPP_ 3 3 4 class vector;4 class Vector; 5 5 6 6 /** Single vector. 7 7 * basically, just a x[3] but with helpful functions 8 8 */ 9 class vector {9 class Vector { 10 10 public: 11 11 double x[NDIM]; 12 12 13 vector();14 vector(double x1, double x2, double x3);15 ~ vector();13 Vector(); 14 Vector(double x1, double x2, double x3); 15 ~Vector(); 16 16 17 double Distance(const vector *y) const;18 double PeriodicDistance(const vector *y, const double *cell_size) const;19 double ScalarProduct(const vector *y) const;20 double Projection(const vector *y) const;17 double Distance(const Vector *y) const; 18 double PeriodicDistance(const Vector *y, const double *cell_size) const; 19 double ScalarProduct(const Vector *y) const; 20 double Projection(const Vector *y) const; 21 21 double Norm() const ; 22 double Angle( vector *y) const;22 double Angle(Vector *y) const; 23 23 24 void AddVector(const vector *y);25 void SubtractVector(const vector *y);26 void CopyVector(const vector *y);27 void RotateVector(const vector *y, const double alpha);28 void ProjectOntoPlane(const vector *y);24 void AddVector(const Vector *y); 25 void SubtractVector(const Vector *y); 26 void CopyVector(const Vector *y); 27 void RotateVector(const Vector *y, const double alpha); 28 void ProjectOntoPlane(const Vector *y); 29 29 void Zero(); 30 30 void One(double one); 31 31 void Init(double x1, double x2, double x3); 32 32 void Normalize(); 33 void Translate(const vector *x);34 void Mirror(const vector *x);33 void Translate(const Vector *x); 34 void Mirror(const Vector *x); 35 35 void Scale(double **factor); 36 36 void Scale(double *factor); … … 39 39 void InverseMatrixMultiplication(double *M); 40 40 void KeepPeriodic(ofstream *out, double *matrix); 41 void LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors);41 void LinearCombinationOfVectors(const Vector *x1, const Vector *x2, const Vector *x3, double *factors); 42 42 43 double CutsPlaneAt( vector *A, vector *B, vector *C);44 bool GetOneNormalVector(const vector *x1);45 bool MakeNormalVector(const vector *y1);46 bool MakeNormalVector(const vector *y1, const vector *y2);47 bool MakeNormalVector(const vector *x1, const vector *x2, const vector *x3);48 bool SolveSystem( vector *x1, vector *x2, vector *y, double alpha, double beta, double c);49 bool LSQdistance( vector **vectors, int dim);43 double CutsPlaneAt(Vector *A, Vector *B, Vector *C); 44 bool GetOneNormalVector(const Vector *x1); 45 bool MakeNormalVector(const Vector *y1); 46 bool MakeNormalVector(const Vector *y1, const Vector *y2); 47 bool MakeNormalVector(const Vector *x1, const Vector *x2, const Vector *x3); 48 bool SolveSystem(Vector *x1, Vector *x2, Vector *y, double alpha, double beta, double c); 49 bool LSQdistance(Vector **vectors, int dim); 50 50 51 51 void AskPosition(double *cell_size, bool check); … … 53 53 }; 54 54 55 ofstream& operator<<(ofstream& ost, vector& m);56 vector& operator+=(vector& a, const vector& b);57 vector& operator*=(vector& a, const double m);58 vector& operator*(const vector& a, const double m);59 vector& operator+(const vector& a, const vector& b);55 ofstream& operator<<(ofstream& ost, Vector& m); 56 Vector& operator+=(Vector& a, const Vector& b); 57 Vector& operator*=(Vector& a, const double m); 58 Vector& operator*(const Vector& a, const double m); 59 Vector& operator+(const Vector& a, const Vector& b); 60 60 61 61 #endif /*VECTOR_HPP_*/
Note:
See TracChangeset
for help on using the changeset viewer.