source: src/LinearAlgebra/Vector.cpp@ 8e9ce1

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 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
Last change on this file since 8e9ce1 was bbf1bd, checked in by Frederik Heber <heber@…>, 15 years ago

Extended VectorContent class.

  • VectorContent formerly has been just a structure to contain the gsl_vector due to forward declaration reasons.
  • now VectorContent is a true wrapper to gsl_vector, i.e. all functionality that is now specific to 3 dimensions has been shifted from GSLVector over to VectorContent.
  • VectorContentView is preserved to allow for VectorContent as a view on a row or column of a matrix.
  • changed and renamed unit test gslvectorunittest -> VectorContentUnitTest
  • GSLVector is not used anymore anywhere
  • one long-sough error was a missing assignment operator filled-in in a wrong manner by the compiler for VectorContent.

Note that:

  • gsl_vector is still used at many places
  • Property mode set to 100644
File size: 14.0 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[6ac7ee]8/** \file vector.cpp
9 *
10 * Function implementations for the class vector.
11 *
12 */
13
[bf3817]14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
[112b09]19#include "Helpers/MemDebug.hpp"
[edb93c]20
[57f243]21#include "LinearAlgebra/Vector.hpp"
[ce3d2b]22#include "VectorContent.hpp"
[952f38]23#include "Helpers/Verbose.hpp"
[b34306]24#include "World.hpp"
[0a4f7f]25#include "Helpers/Assert.hpp"
[753f02]26#include "Helpers/fast_functions.hpp"
[325390]27#include "Exceptions/MathException.hpp"
[6ac7ee]28
[1bd79e]29#include <iostream>
[923b6c]30#include <gsl/gsl_blas.h>
[a439e5]31#include <gsl/gsl_vector.h>
[923b6c]32
[1bd79e]33
34using namespace std;
[6ac7ee]35
[97498a]36
[6ac7ee]37/************************************ Functions for class vector ************************************/
38
39/** Constructor of class vector.
40 */
[753f02]41Vector::Vector()
42{
[bbf1bd]43 content = new VectorContent((size_t) NDIM);
[753f02]44};
[6ac7ee]45
[bbf1bd]46/** Copy constructor.
47 * \param &src source Vector reference
[821907]48 */
[753f02]49Vector::Vector(const Vector& src)
[821907]50{
[bbf1bd]51 content = new VectorContent(*(src.content));
[1bd79e]52}
[821907]53
54/** Constructor of class vector.
[bbf1bd]55 * \param x1 first component
56 * \param x2 second component
57 * \param x3 third component
[821907]58 */
[753f02]59Vector::Vector(const double x1, const double x2, const double x3)
[821907]60{
[bbf1bd]61 content = new VectorContent((size_t) NDIM);
62 content->at(0) = x1;
63 content->at(1) = x2;
64 content->at(2) = x3;
[821907]65};
66
[d74077]67/** Constructor of class vector.
[bbf1bd]68 * \param x[3] three values to initialize Vector with
[d74077]69 */
70Vector::Vector(const double x[3])
71{
[bbf1bd]72 content = new VectorContent((size_t) NDIM);
73 for (size_t i = NDIM; i--; )
74 content->at(i) = x[i];
[d74077]75};
76
[bbf1bd]77/** Copy constructor of class vector from VectorContent.
78 * \note This is destructive, i.e. we take over _content.
79 */
80Vector::Vector(VectorContent *&_content) :
81 content(_content)
82{
83 _content = NULL;
84}
85
86/** Copy constructor of class vector from VectorContent.
87 * \note This is non-destructive, i.e. _content is copied.
88 */
89Vector::Vector(VectorContent &_content)
90{
91 content = new VectorContent(_content);
92}
[325390]93
[bbf1bd]94/** Assignment operator.
95 * \param &src source vector to assign \a *this to
96 * \return reference to \a *this
[6ac7ee]97 */
[0a4f7f]98Vector& Vector::operator=(const Vector& src){
99 // check for self assignment
100 if(&src!=this){
[bbf1bd]101 *content = *(src.content);
[0a4f7f]102 }
103 return *this;
104}
[6ac7ee]105
106/** Desctructor of class vector.
[bbf1bd]107 * Vector::content is deleted.
[6ac7ee]108 */
[d466f0]109Vector::~Vector() {
[ce3d2b]110 delete content;
[d466f0]111};
[6ac7ee]112
113/** Calculates square of distance between this and another vector.
114 * \param *y array to second vector
115 * \return \f$| x - y |^2\f$
116 */
[273382]117double Vector::DistanceSquared(const Vector &y) const
[6ac7ee]118{
[042f82]119 double res = 0.;
120 for (int i=NDIM;i--;)
[d466f0]121 res += (at(i)-y[i])*(at(i)-y[i]);
[042f82]122 return (res);
[6ac7ee]123};
124
125/** Calculates distance between this and another vector.
126 * \param *y array to second vector
127 * \return \f$| x - y |\f$
128 */
[1513a74]129double Vector::distance(const Vector &y) const
[6ac7ee]130{
[273382]131 return (sqrt(DistanceSquared(y)));
[6ac7ee]132};
133
[a439e5]134size_t Vector::GreatestComponent() const
135{
136 int greatest = 0;
137 for (int i=1;i<NDIM;i++) {
138 if (at(i) > at(greatest))
139 greatest = i;
140 }
141 return greatest;
142}
143
144size_t Vector::SmallestComponent() const
145{
146 int smallest = 0;
147 for (int i=1;i<NDIM;i++) {
148 if (at(i) < at(smallest))
149 smallest = i;
150 }
151 return smallest;
152}
153
154
[1513a74]155Vector Vector::getClosestPoint(const Vector &point) const{
156 // the closest point to a single point space is always the single point itself
157 return *this;
158}
159
[6ac7ee]160/** Calculates scalar product between this and another vector.
161 * \param *y array to second vector
162 * \return \f$\langle x, y \rangle\f$
163 */
[273382]164double Vector::ScalarProduct(const Vector &y) const
[6ac7ee]165{
[042f82]166 double res = 0.;
[ce3d2b]167 gsl_blas_ddot(content->content, y.content->content, &res);
[042f82]168 return (res);
[6ac7ee]169};
170
171
172/** Calculates VectorProduct between this and another vector.
[042f82]173 * -# returns the Product in place of vector from which it was initiated
174 * -# ATTENTION: Only three dim.
175 * \param *y array to vector with which to calculate crossproduct
176 * \return \f$ x \times y \f&
[6ac7ee]177 */
[273382]178void Vector::VectorProduct(const Vector &y)
[6ac7ee]179{
[042f82]180 Vector tmp;
[d466f0]181 for(int i=NDIM;i--;)
182 tmp[i] = at((i+1)%NDIM)*y[(i+2)%NDIM] - at((i+2)%NDIM)*y[(i+1)%NDIM];
[753f02]183 (*this) = tmp;
[6ac7ee]184};
185
186
187/** projects this vector onto plane defined by \a *y.
188 * \param *y normal vector of plane
189 * \return \f$\langle x, y \rangle\f$
190 */
[273382]191void Vector::ProjectOntoPlane(const Vector &y)
[6ac7ee]192{
[042f82]193 Vector tmp;
[753f02]194 tmp = y;
[042f82]195 tmp.Normalize();
[753f02]196 tmp.Scale(ScalarProduct(tmp));
197 *this -= tmp;
[2319ed]198};
199
[821907]200/** Calculates the minimum distance of this vector to the plane.
201 * \sa Vector::GetDistanceVectorToPlane()
202 * \param *out output stream for debugging
203 * \param *PlaneNormal normal of plane
204 * \param *PlaneOffset offset of plane
205 * \return distance to plane
206 */
[d4c9ae]207double Vector::DistanceToSpace(const Space &space) const
[821907]208{
[d4c9ae]209 return space.distance(*this);
[c4d4df]210};
211
[6ac7ee]212/** Calculates the projection of a vector onto another \a *y.
213 * \param *y array to second vector
214 */
[273382]215void Vector::ProjectIt(const Vector &y)
[6ac7ee]216{
[753f02]217 (*this) += (-ScalarProduct(y))*y;
[ef9df36]218};
219
220/** Calculates the projection of a vector onto another \a *y.
221 * \param *y array to second vector
222 * \return Vector
223 */
[273382]224Vector Vector::Projection(const Vector &y) const
[ef9df36]225{
[753f02]226 Vector helper = y;
227 helper.Scale((ScalarProduct(y)/y.NormSquared()));
[ef9df36]228
229 return helper;
[6ac7ee]230};
231
232/** Calculates norm of this vector.
233 * \return \f$|x|\f$
234 */
235double Vector::Norm() const
236{
[273382]237 return (sqrt(NormSquared()));
[6ac7ee]238};
239
[d4d0dd]240/** Calculates squared norm of this vector.
241 * \return \f$|x|^2\f$
242 */
243double Vector::NormSquared() const
244{
[273382]245 return (ScalarProduct(*this));
[d4d0dd]246};
247
[6ac7ee]248/** Normalizes this vector.
249 */
250void Vector::Normalize()
251{
[1bd79e]252 double factor = Norm();
253 (*this) *= 1/factor;
[6ac7ee]254};
255
[421a1f]256Vector Vector::getNormalized() const{
257 Vector res= *this;
258 res.Normalize();
259 return res;
260}
261
[6ac7ee]262/** Zeros all components of this vector.
263 */
264void Vector::Zero()
265{
[753f02]266 at(0)=at(1)=at(2)=0;
[6ac7ee]267};
268
269/** Zeros all components of this vector.
270 */
[776b64]271void Vector::One(const double one)
[6ac7ee]272{
[753f02]273 at(0)=at(1)=at(2)=one;
[6ac7ee]274};
275
[9c20aa]276/** Checks whether vector has all components zero.
277 * @return true - vector is zero, false - vector is not
278 */
[54a746]279bool Vector::IsZero() const
[9c20aa]280{
[d466f0]281 return (fabs(at(0))+fabs(at(1))+fabs(at(2)) < MYEPSILON);
[54a746]282};
283
284/** Checks whether vector has length of 1.
285 * @return true - vector is normalized, false - vector is not
286 */
287bool Vector::IsOne() const
288{
289 return (fabs(Norm() - 1.) < MYEPSILON);
[9c20aa]290};
291
[ef9df36]292/** Checks whether vector is normal to \a *normal.
293 * @return true - vector is normalized, false - vector is not
294 */
[273382]295bool Vector::IsNormalTo(const Vector &normal) const
[ef9df36]296{
297 if (ScalarProduct(normal) < MYEPSILON)
298 return true;
299 else
300 return false;
301};
302
[b998c3]303/** Checks whether vector is normal to \a *normal.
304 * @return true - vector is normalized, false - vector is not
305 */
[273382]306bool Vector::IsEqualTo(const Vector &a) const
[b998c3]307{
308 bool status = true;
309 for (int i=0;i<NDIM;i++) {
[d466f0]310 if (fabs(at(i) - a[i]) > MYEPSILON)
[b998c3]311 status = false;
312 }
313 return status;
314};
315
[6ac7ee]316/** Calculates the angle between this and another vector.
317 * \param *y array to second vector
318 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
319 */
[273382]320double Vector::Angle(const Vector &y) const
[6ac7ee]321{
[753f02]322 double norm1 = Norm(), norm2 = y.Norm();
[ef9df36]323 double angle = -1;
[d4d0dd]324 if ((fabs(norm1) > MYEPSILON) && (fabs(norm2) > MYEPSILON))
325 angle = this->ScalarProduct(y)/norm1/norm2;
[02da9e]326 // -1-MYEPSILON occured due to numerical imprecision, catch ...
[e138de]327 //Log() << Verbose(2) << "INFO: acos(-1) = " << acos(-1) << ", acos(-1+MYEPSILON) = " << acos(-1+MYEPSILON) << ", acos(-1-MYEPSILON) = " << acos(-1-MYEPSILON) << "." << endl;
[02da9e]328 if (angle < -1)
329 angle = -1;
330 if (angle > 1)
331 angle = 1;
[042f82]332 return acos(angle);
[6ac7ee]333};
334
[0a4f7f]335
336double& Vector::operator[](size_t i){
[753f02]337 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
[ce3d2b]338 return *gsl_vector_ptr (content->content, i);
[0a4f7f]339}
340
341const double& Vector::operator[](size_t i) const{
[753f02]342 ASSERT(i<=NDIM && i>=0,"Vector Index out of Range");
[ce3d2b]343 return *gsl_vector_ptr (content->content, i);
[0a4f7f]344}
345
346double& Vector::at(size_t i){
347 return (*this)[i];
348}
349
350const double& Vector::at(size_t i) const{
351 return (*this)[i];
352}
353
[ae21cbd]354VectorContent* Vector::get() const
355{
[0c7ed8]356 return content;
[0a4f7f]357}
[6ac7ee]358
[ef9df36]359/** Compares vector \a to vector \a b component-wise.
360 * \param a base vector
361 * \param b vector components to add
362 * \return a == b
363 */
[72e7fa]364bool Vector::operator==(const Vector& b) const
[ef9df36]365{
[1bd79e]366 return IsEqualTo(b);
[ef9df36]367};
368
[fa5a6a]369bool Vector::operator!=(const Vector& b) const
370{
371 return !IsEqualTo(b);
372}
373
[6ac7ee]374/** Sums vector \a to this lhs component-wise.
375 * \param a base vector
376 * \param b vector components to add
377 * \return lhs + a
378 */
[72e7fa]379const Vector& Vector::operator+=(const Vector& b)
[6ac7ee]380{
[273382]381 this->AddVector(b);
[72e7fa]382 return *this;
[6ac7ee]383};
[54a746]384
385/** Subtracts vector \a from this lhs component-wise.
386 * \param a base vector
387 * \param b vector components to add
388 * \return lhs - a
389 */
[72e7fa]390const Vector& Vector::operator-=(const Vector& b)
[54a746]391{
[273382]392 this->SubtractVector(b);
[72e7fa]393 return *this;
[54a746]394};
395
[6ac7ee]396/** factor each component of \a a times a double \a m.
397 * \param a base vector
398 * \param m factor
399 * \return lhs.x[i] * m
400 */
[b84d5d]401const Vector& operator*=(Vector& a, const double m)
[6ac7ee]402{
[042f82]403 a.Scale(m);
404 return a;
[6ac7ee]405};
406
[042f82]407/** Sums two vectors \a and \b component-wise.
[6ac7ee]408 * \param a first vector
409 * \param b second vector
410 * \return a + b
411 */
[72e7fa]412Vector const Vector::operator+(const Vector& b) const
[6ac7ee]413{
[72e7fa]414 Vector x = *this;
[273382]415 x.AddVector(b);
[b84d5d]416 return x;
[6ac7ee]417};
418
[54a746]419/** Subtracts vector \a from \b component-wise.
420 * \param a first vector
421 * \param b second vector
422 * \return a - b
423 */
[72e7fa]424Vector const Vector::operator-(const Vector& b) const
[54a746]425{
[72e7fa]426 Vector x = *this;
[273382]427 x.SubtractVector(b);
[b84d5d]428 return x;
[54a746]429};
430
[6ac7ee]431/** Factors given vector \a a times \a m.
432 * \param a vector
433 * \param m factor
[54a746]434 * \return m * a
[6ac7ee]435 */
[b84d5d]436Vector const operator*(const Vector& a, const double m)
[6ac7ee]437{
[b84d5d]438 Vector x(a);
439 x.Scale(m);
440 return x;
[6ac7ee]441};
442
[54a746]443/** Factors given vector \a a times \a m.
444 * \param m factor
445 * \param a vector
446 * \return m * a
447 */
[b84d5d]448Vector const operator*(const double m, const Vector& a )
[54a746]449{
[b84d5d]450 Vector x(a);
451 x.Scale(m);
452 return x;
[54a746]453};
454
[9c20aa]455ostream& operator<<(ostream& ost, const Vector& m)
[6ac7ee]456{
[042f82]457 ost << "(";
458 for (int i=0;i<NDIM;i++) {
[0a4f7f]459 ost << m[i];
[042f82]460 if (i != 2)
461 ost << ",";
462 }
463 ost << ")";
464 return ost;
[6ac7ee]465};
466
467
[1bd79e]468void Vector::ScaleAll(const double *factor)
[6ac7ee]469{
[042f82]470 for (int i=NDIM;i--;)
[d466f0]471 at(i) *= factor[i];
[6ac7ee]472};
473
[b5bf84]474void Vector::ScaleAll(const Vector &factor){
[ce3d2b]475 gsl_vector_mul(content->content, factor.content->content);
[b5bf84]476}
[6ac7ee]477
[1bd79e]478
[776b64]479void Vector::Scale(const double factor)
[6ac7ee]480{
[ce3d2b]481 gsl_vector_scale(content->content,factor);
[6ac7ee]482};
483
[45ef76]484std::pair<Vector,Vector> Vector::partition(const Vector &rhs) const{
485 double factor = ScalarProduct(rhs)/rhs.NormSquared();
486 Vector res= factor * rhs;
487 return make_pair(res,(*this)-res);
488}
489
490std::pair<pointset,Vector> Vector::partition(const pointset &points) const{
491 Vector helper = *this;
492 pointset res;
493 for(pointset::const_iterator iter=points.begin();iter!=points.end();++iter){
494 pair<Vector,Vector> currPart = helper.partition(*iter);
495 res.push_back(currPart.first);
496 helper = currPart.second;
497 }
498 return make_pair(res,helper);
499}
500
[6ac7ee]501/** Creates this vector as the b y *factors' components scaled linear combination of the given three.
502 * this vector = x1*factors[0] + x2* factors[1] + x3*factors[2]
503 * \param *x1 first vector
504 * \param *x2 second vector
505 * \param *x3 third vector
506 * \param *factors three-component vector with the factor for each given vector
507 */
[273382]508void Vector::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
[6ac7ee]509{
[273382]510 (*this) = (factors[0]*x1) +
511 (factors[1]*x2) +
512 (factors[2]*x3);
[6ac7ee]513};
514
515/** Calculates orthonormal vector to one given vectors.
516 * Just subtracts the projection onto the given vector from this vector.
[ef9df36]517 * The removed part of the vector is Vector::Projection()
[6ac7ee]518 * \param *x1 vector
519 * \return true - success, false - vector is zero
520 */
[0a4f7f]521bool Vector::MakeNormalTo(const Vector &y1)
[6ac7ee]522{
[042f82]523 bool result = false;
[753f02]524 double factor = y1.ScalarProduct(*this)/y1.NormSquared();
[45ef76]525 Vector x1 = factor * y1;
[753f02]526 SubtractVector(x1);
[042f82]527 for (int i=NDIM;i--;)
[d466f0]528 result = result || (fabs(at(i)) > MYEPSILON);
[6ac7ee]529
[042f82]530 return result;
[6ac7ee]531};
532
533/** Creates this vector as one of the possible orthonormal ones to the given one.
534 * Just scan how many components of given *vector are unequal to zero and
535 * try to get the skp of both to be zero accordingly.
536 * \param *vector given vector
537 * \return true - success, false - failure (null vector given)
538 */
[273382]539bool Vector::GetOneNormalVector(const Vector &GivenVector)
[6ac7ee]540{
[042f82]541 int Components[NDIM]; // contains indices of non-zero components
542 int Last = 0; // count the number of non-zero entries in vector
543 int j; // loop variables
544 double norm;
545
546 for (j=NDIM;j--;)
547 Components[j] = -1;
[1829c4]548
549 // in two component-systems we need to find the one position that is zero
550 int zeroPos = -1;
[042f82]551 // find two components != 0
[1829c4]552 for (j=0;j<NDIM;j++){
[753f02]553 if (fabs(GivenVector[j]) > MYEPSILON)
[042f82]554 Components[Last++] = j;
[1829c4]555 else
556 // this our zero Position
557 zeroPos = j;
558 }
[042f82]559
560 switch(Last) {
561 case 3: // threecomponent system
[1829c4]562 // the position of the zero is arbitrary in three component systems
563 zeroPos = Components[2];
[042f82]564 case 2: // two component system
[753f02]565 norm = sqrt(1./(GivenVector[Components[1]]*GivenVector[Components[1]]) + 1./(GivenVector[Components[0]]*GivenVector[Components[0]]));
[1829c4]566 at(zeroPos) = 0.;
[042f82]567 // in skp both remaining parts shall become zero but with opposite sign and third is zero
[1829c4]568 at(Components[1]) = -1./GivenVector[Components[1]] / norm;
569 at(Components[0]) = 1./GivenVector[Components[0]] / norm;
[042f82]570 return true;
571 break;
572 case 1: // one component system
573 // set sole non-zero component to 0, and one of the other zero component pendants to 1
[1829c4]574 at((Components[0]+2)%NDIM) = 0.;
575 at((Components[0]+1)%NDIM) = 1.;
576 at(Components[0]) = 0.;
[042f82]577 return true;
578 break;
579 default:
580 return false;
581 }
[6ac7ee]582};
583
584/** Adds vector \a *y componentwise.
585 * \param *y vector
586 */
[273382]587void Vector::AddVector(const Vector &y)
[6ac7ee]588{
[ce3d2b]589 gsl_vector_add(content->content, y.content->content);
[6ac7ee]590}
591
592/** Adds vector \a *y componentwise.
593 * \param *y vector
594 */
[273382]595void Vector::SubtractVector(const Vector &y)
[6ac7ee]596{
[ce3d2b]597 gsl_vector_sub(content->content, y.content->content);
[ef9df36]598}
599
[005e18]600
601// some comonly used vectors
602const Vector zeroVec(0,0,0);
[407782]603const Vector unitVec[NDIM]={Vector(1,0,0),Vector(0,1,0),Vector(0,0,1)};
Note: See TracBrowser for help on using the repository browser.