--- trunk/src/math/Vector.hpp 2006/05/17 21:51:42 963 +++ trunk/src/math/Vector.hpp 2011/08/26 17:55:44 1615 @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,6 +28,15 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ /** @@ -54,7 +54,7 @@ #include #include #include "config.h" -namespace oopse { +namespace OpenMD { static const RealType epsilon = 0.000001; @@ -271,6 +271,20 @@ namespace oopse { } /** + * Sets the elements of this vector to the multiplication of + * elements of two other vectors. Not to be confused with scalar + * multiplication (mul) or dot products. + * + * (*this.data_[i] = v1.data_[i] * v2.data_[i]). + * @param v1 the first vector + * @param v2 the second vector + */ + inline void Vmul( const Vector& v1, const Vector& v2) { + for (unsigned int i = 0; i < Dim; i++) + this->data_[i] = v1.data_[i] * v2.data_[i]; + } + + /** * Sets the value of this vector to the scalar division of itself (*this /= s ). * @param s the scalar value */ @@ -289,6 +303,21 @@ namespace oopse { this->data_[i] = v1.data_[i] / s; } + /** + * Sets the elements of this vector to the division of + * elements of two other vectors. Not to be confused with scalar + * division (div) + * + * (*this.data_[i] = v1.data_[i] / v2.data_[i]). + * @param v1 the first vector + * @param v2 the second vector + */ + inline void Vdiv( const Vector& v1, const Vector& v2) { + for (unsigned int i = 0; i < Dim; i++) + this->data_[i] = v1.data_[i] / v2.data_[i]; + } + + /** @see #add */ inline Vector& operator +=( const Vector& v1 ) { add(v1); @@ -314,6 +343,30 @@ namespace oopse { } /** + * Returns the sum of all elements of this vector. + * @return the sum of all elements of this vector + */ + inline Real sum() { + Real tmp; + tmp = 0; + for (unsigned int i = 0; i < Dim; i++) + tmp += this->data_[i]; + return tmp; + } + + /** + * Returns the product of all elements of this vector. + * @return the product of all elements of this vector + */ + inline Real componentProduct() { + Real tmp; + tmp = 1; + for (unsigned int i = 0; i < Dim; i++) + tmp *= this->data_[i]; + return tmp; + } + + /** * Returns the length of this vector. * @return the length of this vector */ @@ -335,7 +388,7 @@ namespace oopse { len = length(); - //if (len < oopse:epsilon) + //if (len < OpenMD::NumericConstant::epsilon) // throw(); *this /= len; @@ -446,7 +499,31 @@ namespace oopse { return tmp; } + + + /** + * Returns the wide dot product of three Vectors. Compare with + * Rapaport's VWDot function. + * + * @param v1 first vector + * @param v2 second vector + * @param v3 third vector + * @return the wide dot product of v1, v2, and v3. + */ + template + inline Real dot( const Vector& v1, const Vector& v2, const Vector& v3 ) { + Real tmp; + tmp = 0; + + for (unsigned int i = 0; i < Dim; i++) + tmp += v1[i] * v2[i] * v3[i]; + + return tmp; + } + + + /** * Returns the distance between two Vectors * @param v1 first vector * @param v2 second vector