36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
73 |
|
inline bool equal(RealType e1, RealType e2) { |
74 |
|
return fabs(e1 - e2) < epsilon; |
75 |
|
} |
75 |
– |
|
76 |
|
|
77 |
|
/** |
78 |
|
* @class Vector Vector.hpp "math/Vector.hpp" |
107 |
|
return *this; |
108 |
|
} |
109 |
|
|
110 |
< |
template<typename T> |
111 |
< |
inline Vector(const T& s){ |
110 |
> |
// template<typename T> |
111 |
> |
// inline Vector(const T& s){ |
112 |
> |
inline Vector(const Real& s) { |
113 |
|
for (unsigned int i = 0; i < Dim; i++) |
114 |
< |
this->data_[i] = s; |
114 |
> |
this->data_[i] = s; |
115 |
|
} |
116 |
|
|
117 |
|
/** Constructs and initializes a Vector from an array */ |
269 |
|
inline void mul( const Vector<Real, Dim>& v1, Real s) { |
270 |
|
for (unsigned int i = 0; i < Dim; i++) |
271 |
|
this->data_[i] = s * v1.data_[i]; |
272 |
+ |
} |
273 |
+ |
|
274 |
+ |
/** |
275 |
+ |
* Sets the elements of this vector to the multiplication of |
276 |
+ |
* elements of two other vectors. Not to be confused with scalar |
277 |
+ |
* multiplication (mul) or dot products. |
278 |
+ |
* |
279 |
+ |
* (*this.data_[i] = v1.data_[i] * v2.data_[i]). |
280 |
+ |
* @param v1 the first vector |
281 |
+ |
* @param v2 the second vector |
282 |
+ |
*/ |
283 |
+ |
inline void Vmul( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2) { |
284 |
+ |
for (unsigned int i = 0; i < Dim; i++) |
285 |
+ |
this->data_[i] = v1.data_[i] * v2.data_[i]; |
286 |
|
} |
287 |
|
|
288 |
+ |
/* replaces the elements with the absolute values of those elements */ |
289 |
+ |
inline Vector<Real, Dim>& abs() { |
290 |
+ |
for (unsigned int i = 0; i < Dim; i++) { |
291 |
+ |
this->data_[i] = std::abs(this->data_[i]); |
292 |
+ |
} |
293 |
+ |
return *this; |
294 |
+ |
} |
295 |
+ |
|
296 |
+ |
/* returns the maximum value in this vector */ |
297 |
+ |
inline Real max() { |
298 |
+ |
Real val = this->data_[0]; |
299 |
+ |
for (unsigned int i = 0; i < Dim; i++) { |
300 |
+ |
if (this->data_[i] > val) val = this->data_[i]; |
301 |
+ |
} |
302 |
+ |
return val; |
303 |
+ |
} |
304 |
+ |
|
305 |
|
/** |
306 |
|
* Sets the value of this vector to the scalar division of itself (*this /= s ). |
307 |
|
* @param s the scalar value |
321 |
|
this->data_[i] = v1.data_[i] / s; |
322 |
|
} |
323 |
|
|
324 |
+ |
/** |
325 |
+ |
* Sets the elements of this vector to the division of |
326 |
+ |
* elements of two other vectors. Not to be confused with scalar |
327 |
+ |
* division (div) |
328 |
+ |
* |
329 |
+ |
* (*this.data_[i] = v1.data_[i] / v2.data_[i]). |
330 |
+ |
* @param v1 the first vector |
331 |
+ |
* @param v2 the second vector |
332 |
+ |
*/ |
333 |
+ |
inline void Vdiv( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2) { |
334 |
+ |
for (unsigned int i = 0; i < Dim; i++) |
335 |
+ |
this->data_[i] = v1.data_[i] / v2.data_[i]; |
336 |
+ |
} |
337 |
+ |
|
338 |
+ |
|
339 |
|
/** @see #add */ |
340 |
|
inline Vector<Real, Dim>& operator +=( const Vector<Real, Dim>& v1 ) { |
341 |
|
add(v1); |
371 |
|
tmp += this->data_[i]; |
372 |
|
return tmp; |
373 |
|
} |
374 |
+ |
|
375 |
+ |
/** |
376 |
+ |
* Returns the product of all elements of this vector. |
377 |
+ |
* @return the product of all elements of this vector |
378 |
+ |
*/ |
379 |
+ |
inline Real componentProduct() { |
380 |
+ |
Real tmp; |
381 |
+ |
tmp = 1; |
382 |
+ |
for (unsigned int i = 0; i < Dim; i++) |
383 |
+ |
tmp *= this->data_[i]; |
384 |
+ |
return tmp; |
385 |
+ |
} |
386 |
|
|
387 |
|
/** |
388 |
|
* Returns the length of this vector. |
517 |
|
return tmp; |
518 |
|
} |
519 |
|
|
520 |
+ |
|
521 |
+ |
|
522 |
+ |
|
523 |
|
/** |
524 |
+ |
* Returns the wide dot product of three Vectors. Compare with |
525 |
+ |
* Rapaport's VWDot function. |
526 |
+ |
* |
527 |
+ |
* @param v1 first vector |
528 |
+ |
* @param v2 second vector |
529 |
+ |
* @param v3 third vector |
530 |
+ |
* @return the wide dot product of v1, v2, and v3. |
531 |
+ |
*/ |
532 |
+ |
template<typename Real, unsigned int Dim> |
533 |
+ |
inline Real dot( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2, const Vector<Real, Dim>& v3 ) { |
534 |
+ |
Real tmp; |
535 |
+ |
tmp = 0; |
536 |
+ |
|
537 |
+ |
for (unsigned int i = 0; i < Dim; i++) |
538 |
+ |
tmp += v1[i] * v2[i] * v3[i]; |
539 |
+ |
|
540 |
+ |
return tmp; |
541 |
+ |
} |
542 |
+ |
|
543 |
+ |
|
544 |
+ |
/** |
545 |
|
* Returns the distance between two Vectors |
546 |
|
* @param v1 first vector |
547 |
|
* @param v2 second vector |