- Timestamp:
- Jun 17, 2010, 3:09:22 PM (15 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:
- d386e8
- Parents:
- 5f5a7b (diff), 0c7ed8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gslvector.cpp
r5f5a7b r1dc9ec 13 13 #include "gslvector.hpp" 14 14 #include "defs.hpp" 15 #include "vector.hpp" 15 16 16 17 /** Constructor of class GSLVector. … … 61 62 gsl_vector_memcpy (vector, &m.vector); 62 63 }; 64 65 /** 66 * This function sets the GSLvector from an ordinary vector. 67 * 68 * Takes access to the internal gsl_vector and copies it 69 */ 70 void GSLVector::SetFromVector(Vector &v){ 71 gsl_vector_memcpy (vector, v.get()); 72 } 63 73 64 74 /** This function returns the i-th element of a vector. -
src/gslvector.hpp
r5f5a7b r1dc9ec 24 24 25 25 class GSLVector; 26 class Vector; 26 27 27 28 /********************************************** declarations *******************************/ … … 38 39 // Accessing 39 40 void SetFromDoubleArray(double *x); 41 void SetFromVector(Vector &v); 40 42 double Get(size_t m) const; 41 43 void Set(size_t m, double x); -
src/linearsystemofequations.cpp
r5f5a7b r1dc9ec 56 56 { 57 57 assert ( columns == NDIM && "Vector class is always three-dimensional, unlike this LEqS!"); 58 b->SetFrom DoubleArray(x->get());58 b->SetFromVector(*x); 59 59 }; 60 60 -
src/vector.cpp
r5f5a7b r1dc9ec 24 24 Vector::Vector() 25 25 { 26 x[0] = x[1] = x[2] = 0.;26 content = gsl_vector_calloc (NDIM); 27 27 }; 28 28 … … 33 33 Vector::Vector(const Vector& src) 34 34 { 35 x[0] = src[0]; 36 x[1] = src[1]; 37 x[2] = src[2]; 35 content = gsl_vector_alloc(NDIM); 36 gsl_vector_set(content,0,src[0]); 37 gsl_vector_set(content,1,src[1]); 38 gsl_vector_set(content,2,src[2]); 38 39 } 39 40 … … 42 43 Vector::Vector(const double x1, const double x2, const double x3) 43 44 { 44 x[0] = x1; 45 x[1] = x2; 46 x[2] = x3; 45 content = gsl_vector_alloc(NDIM); 46 gsl_vector_set(content,0,x1); 47 gsl_vector_set(content,1,x2); 48 gsl_vector_set(content,2,x3); 47 49 }; 48 50 … … 53 55 // check for self assignment 54 56 if(&src!=this){ 55 x[0] = src[0];56 x[1] = src[1];57 x[2] = src[2];57 gsl_vector_set(content,0,src[0]); 58 gsl_vector_set(content,1,src[1]); 59 gsl_vector_set(content,2,src[2]); 58 60 } 59 61 return *this; … … 62 64 /** Desctructor of class vector. 63 65 */ 64 Vector::~Vector() {}; 66 Vector::~Vector() { 67 gsl_vector_free(content); 68 }; 65 69 66 70 /** Calculates square of distance between this and another vector. … … 72 76 double res = 0.; 73 77 for (int i=NDIM;i--;) 74 res += ( x[i]-y[i])*(x[i]-y[i]);78 res += (at(i)-y[i])*(at(i)-y[i]); 75 79 return (res); 76 80 }; … … 200 204 double res = 0.; 201 205 for (int i=NDIM;i--;) 202 res += x[i]*y[i];206 res += at(i)*y[i]; 203 207 return (res); 204 208 }; … … 214 218 { 215 219 Vector tmp; 216 tmp[0] = x[1]* y[2] - x[2]* y[1]; 217 tmp[1] = x[2]* y[0] - x[0]* y[2]; 218 tmp[2] = x[0]* y[1] - x[1]* y[0]; 220 for(int i=NDIM;i--;) 221 tmp[i] = at((i+1)%NDIM)*y[(i+2)%NDIM] - at((i+2)%NDIM)*y[(i+1)%NDIM]; 219 222 (*this) = tmp; 220 223 }; … … 309 312 bool Vector::IsZero() const 310 313 { 311 return (fabs( x[0])+fabs(x[1])+fabs(x[2]) < MYEPSILON);314 return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON); 312 315 }; 313 316 … … 338 341 bool status = true; 339 342 for (int i=0;i<NDIM;i++) { 340 if (fabs( x[i]- a[i]) > MYEPSILON)343 if (fabs(at(i) - a[i]) > MYEPSILON) 341 344 status = false; 342 345 } … … 366 369 double& Vector::operator[](size_t i){ 367 370 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 368 return x[i];371 return *gsl_vector_ptr (content, i); 369 372 } 370 373 371 374 const double& Vector::operator[](size_t i) const{ 372 375 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range"); 373 return x[i];376 return *gsl_vector_ptr (content, i); 374 377 } 375 378 … … 382 385 } 383 386 384 double* Vector::get(){385 return x;387 gsl_vector* Vector::get(){ 388 return content; 386 389 } 387 390 … … 498 501 { 499 502 for (int i=NDIM;i--;) 500 x[i]*= factor[i];503 at(i) *= factor[i]; 501 504 }; 502 505 … … 506 509 { 507 510 for (int i=NDIM;i--;) 508 x[i]*= factor;511 at(i) *= factor; 509 512 }; 510 513 … … 518 521 // truncate to [0,1] for each axis 519 522 for (int i=0;i<NDIM;i++) { 520 // x[i]+= 0.5; // set to center of box521 while ( x[i]>= 1.)522 x[i]-= 1.;523 while ( x[i]< 0.)524 x[i]+= 1.;523 //at(i) += 0.5; // set to center of box 524 while (at(i) >= 1.) 525 at(i) -= 1.; 526 while (at(i) < 0.) 527 at(i) += 1.; 525 528 } 526 529 MatrixMultiplication(M); … … 549 552 void Vector::MatrixMultiplication(const double * const M) 550 553 { 554 Vector tmp; 551 555 // do the matrix multiplication 552 at(0) = M[0]*x[0]+M[3]*x[1]+M[6]*x[2]; 553 at(1) = M[1]*x[0]+M[4]*x[1]+M[7]*x[2]; 554 at(2) = M[2]*x[0]+M[5]*x[1]+M[8]*x[2]; 556 for(int i=NDIM;i--;) 557 tmp[i] = M[i]*at(0)+M[i+3]*at(1)+M[i+6]*at(2); 558 559 (*this) = tmp; 555 560 }; 556 561 … … 577 582 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 578 583 579 // do the matrix multiplication 580 at(0) = B[0]*x[0]+B[3]*x[1]+B[6]*x[2]; 581 at(1) = B[1]*x[0]+B[4]*x[1]+B[7]*x[2]; 582 at(2) = B[2]*x[0]+B[5]*x[1]+B[8]*x[2]; 584 MatrixMultiplication(B); 583 585 584 586 return true; … … 616 618 SubtractVector(x1); 617 619 for (int i=NDIM;i--;) 618 result = result || (fabs( x[i]) > MYEPSILON);620 result = result || (fabs(at(i)) > MYEPSILON); 619 621 620 622 return result; … … 678 680 { 679 681 for(int i=NDIM;i--;) 680 x[i]+= y[i];682 at(i) += y[i]; 681 683 } 682 684 … … 687 689 { 688 690 for(int i=NDIM;i--;) 689 x[i]-= y[i];691 at(i) -= y[i]; 690 692 } 691 693 -
src/vector.hpp
r5f5a7b r1dc9ec 31 31 */ 32 32 class Vector : public Space{ 33 protected:34 // this struct is used to indicate calls to the Baseconstructor from inside vectors.35 struct Baseconstructor{};36 33 public: 37 34 … … 82 79 83 80 // Access to internal structure 84 double* get();81 gsl_vector* get(); 85 82 86 83 // Methods that are derived directly from other methods … … 107 104 108 105 private: 109 double x[NDIM];106 gsl_vector *content; 110 107 111 108 };
Note:
See TracChangeset
for help on using the changeset viewer.