ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/math/Vector.hpp
(Generate patch)

Comparing trunk/src/math/Vector.hpp (file contents):
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1615 by gezelter, Fri Aug 26 17:55:44 2011 UTC

# Line 268 | Line 268 | namespace OpenMD {
268      inline void mul( const Vector<Real, Dim>& v1, Real s) {
269        for (unsigned int i = 0; i < Dim; i++)
270          this->data_[i] = s * v1.data_[i];
271 +    }
272 +
273 +    /**
274 +     * Sets the elements of this vector to the multiplication of
275 +     * elements of two other vectors.  Not to be confused with scalar
276 +     * multiplication (mul) or dot products.
277 +     *
278 +     * (*this.data_[i] =  v1.data_[i] * v2.data_[i]).
279 +     * @param v1 the first vector            
280 +     * @param v2 the second vector
281 +     */
282 +    inline void Vmul( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2) {
283 +      for (unsigned int i = 0; i < Dim; i++)
284 +        this->data_[i] = v1.data_[i] * v2.data_[i];
285      }
286  
287      /**
# Line 287 | Line 301 | namespace OpenMD {
301      inline void div( const Vector<Real, Dim>& v1, Real s ) {
302        for (unsigned int i = 0; i < Dim; i++)
303          this->data_[i] = v1.data_[i] / s;
304 +    }
305 +
306 +    /**
307 +     * Sets the elements of this vector to the division of
308 +     * elements of two other vectors.  Not to be confused with scalar
309 +     * division (div)
310 +     *
311 +     * (*this.data_[i] =  v1.data_[i] / v2.data_[i]).
312 +     * @param v1 the first vector            
313 +     * @param v2 the second vector
314 +     */
315 +    inline void Vdiv( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2) {
316 +      for (unsigned int i = 0; i < Dim; i++)
317 +        this->data_[i] = v1.data_[i] / v2.data_[i];
318      }
319  
320 +
321      /** @see #add */
322      inline Vector<Real, Dim>& operator +=( const Vector<Real, Dim>& v1 ) {
323        add(v1);
# Line 324 | Line 353 | namespace OpenMD {
353          tmp += this->data_[i];
354        return tmp;  
355      }
356 +
357 +    /**
358 +     * Returns the product of all elements of this vector.
359 +     * @return the product of all elements of this vector
360 +     */
361 +    inline Real componentProduct() {
362 +      Real tmp;
363 +      tmp = 1;
364 +      for (unsigned int i = 0; i < Dim; i++)
365 +        tmp *= this->data_[i];
366 +      return tmp;  
367 +    }
368              
369      /**
370       * Returns the length of this vector.
# Line 458 | Line 499 | namespace OpenMD {
499      return tmp;
500    }
501  
502 +
503 +  
504 +
505    /**
506 +   * Returns the wide dot product of three Vectors.  Compare with
507 +   * Rapaport's VWDot function.
508 +   *
509 +   * @param v1 first vector
510 +   * @param v2 second vector
511 +   * @param v3 third vector
512 +   * @return the wide dot product of v1, v2, and v3.
513 +   */
514 +  template<typename Real, unsigned int Dim>    
515 +  inline Real dot( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2, const Vector<Real, Dim>& v3 ) {
516 +    Real tmp;
517 +    tmp = 0;
518 +
519 +    for (unsigned int i = 0; i < Dim; i++)
520 +      tmp += v1[i] * v2[i] * v3[i];
521 +
522 +    return tmp;
523 +  }
524 +
525 +
526 +  /**
527     * Returns the distance between  two Vectors
528     * @param v1 first vector
529     * @param v2 second vector

Comparing trunk/src/math/Vector.hpp (property svn:keywords):
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
Revision 1615 by gezelter, Fri Aug 26 17:55:44 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines