22 #ifndef __PLUMED_tools_Vector_h
23 #define __PLUMED_tools_Vector_h
167 template <
unsigned n>
169 for(
unsigned i=0;i<
n;i++) d[i]=0.0;
172 template <
unsigned n>
174 for(
unsigned i=0;i<
n;i++) d[i]=0.0;
177 template <
unsigned n>
182 template <
unsigned n>
187 template <
unsigned n>
192 template <
unsigned n>
197 template <
unsigned n>
199 for(
unsigned i=0;i<
n;i++) d[i]+=b.
d[i];
203 template <
unsigned n>
205 for(
unsigned i=0;i<
n;i++) d[i]-=b.
d[i];
209 template <
unsigned n>
211 for(
unsigned i=0;i<
n;i++) d[i]*=s;
215 template <
unsigned n>
221 template <
unsigned n>
226 template <
unsigned n>
229 for(
unsigned i=0;i<
n;i++) r[i]=-d[i];
233 template <
unsigned n>
239 template <
unsigned n>
245 template <
unsigned n>
251 template <
unsigned n>
256 template <
unsigned n>
261 template <
unsigned n>
266 template <
unsigned n>
269 for(
unsigned i=0;i<
n;i++) r+=d[i]*d[i];
273 template <
unsigned n>
276 for(
unsigned i=0;i<
n;i++) r+=v1[i]*v2[i];
283 return v1[0]*v2[0]+v1[1]*v2[1];
289 return d[0]*d[0]+d[1]*d[1];
295 return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2];
301 return d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
307 return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]+v1[3]*v2[3];
313 return d[0]*d[0]+d[1]*d[1]+d[2]*d[2]+d[3]*d[3];
319 v1[1]*v2[2]-v1[2]*v2[1],
320 v1[2]*v2[0]-v1[0]*v2[2],
321 v1[0]*v2[1]-v1[1]*v2[0]);
VectorGeneric & operator-=(const VectorGeneric &b)
decrement
VectorGeneric & operator/=(double s)
divide
double modulo() const
Compute the modulo.
VectorGeneric< 3 > crossProduct(const VectorGeneric< 3 > &v1, const VectorGeneric< 3 > &v2)
Class implementing fixed size vectors of doubles.
friend VectorGeneric< m > operator*(double, const VectorGeneric< m > &)
return s*v
VectorGeneric & operator*=(double s)
multiply
TensorGeneric< n, m > operator*(const TensorGeneric< n, m > &t1, double s)
double & operator[](unsigned i)
array-like access [i]
void zero()
set it to zero
TensorGeneric< n, m > operator/(const TensorGeneric< n, m > &t1, double s)
VectorGeneric< 3 > Vector3d
Alias for three dimensional vectors.
VectorGeneric< 4 > Vector4d
Alias for four dimensional vectors.
TensorGeneric< n, m > operator-(const TensorGeneric< n, m > &t1, const TensorGeneric< n, m > &t2)
VectorGeneric< n > delta(const VectorGeneric< n > &v1, const VectorGeneric< n > &v2)
T dotProduct(const std::vector< T > &A, const std::vector< T > &B)
Calculate the dot product between two vectors.
double modulo2() const
compute the squared modulo
friend VectorGeneric< 3 > crossProduct(const VectorGeneric< 3 > &, const VectorGeneric< 3 > &)
return v1 .vector.
double & operator()(unsigned i)
parenthesis access (i)
double modulo2(const VectorGeneric< n > &v)
TensorGeneric< n, m > operator+(const TensorGeneric< n, m > &t1, const TensorGeneric< n, m > &t2)
VectorGeneric operator+() const
sign +
VectorGeneric & operator+=(const VectorGeneric &b)
increment
friend VectorGeneric< m > operator/(const VectorGeneric< m > &, double)
return v/s
VectorGeneric operator-() const
sign -
double modulo(const VectorGeneric< n > &v)
Vector3d Vector
Alias for three dimensional vectors.
VectorGeneric< 2 > Vector2d
Alias for two dimensional vectors.
VectorGeneric()
create it null
friend VectorGeneric< m > delta(const VectorGeneric< m > &v1, const VectorGeneric< m > &v2)
return v2-v1
friend double dotProduct(const VectorGeneric< m > &, const VectorGeneric< m > &)
return v1 .scalar. v2