ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/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.
branches/development/src/math/Vector.hpp (file contents), Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC

# Line 36 | Line 36
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   /**
# Line 72 | Line 73 | namespace OpenMD {
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"
# Line 271 | Line 271 | namespace OpenMD {
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 +    /* replaces the elements with the absolute values of those elements */
288 +    inline Vector<Real, Dim>& abs() {
289 +      for (unsigned int i = 0; i < Dim; i++) {
290 +        this->data_[i] = std::abs(this->data_[i]);
291 +      }
292 +      return *this;
293 +    }
294 +    
295 +    /* returns the maximum value in this vector */
296 +    inline Real max() {
297 +      Real val = this->data_[0];
298 +      for (unsigned int i = 0; i < Dim; i++) {
299 +        if (this->data_[i] > val) val = this->data_[i];
300 +      }
301 +      return val;
302 +    }
303 +    
304 +    /**
305       * Sets the value of this vector to the scalar division of itself  (*this /= s ).
306       * @param s the scalar value
307       */            
# Line 287 | Line 318 | namespace OpenMD {
318      inline void div( const Vector<Real, Dim>& v1, Real s ) {
319        for (unsigned int i = 0; i < Dim; i++)
320          this->data_[i] = v1.data_[i] / s;
321 +    }
322 +
323 +    /**
324 +     * Sets the elements of this vector to the division of
325 +     * elements of two other vectors.  Not to be confused with scalar
326 +     * division (div)
327 +     *
328 +     * (*this.data_[i] =  v1.data_[i] / v2.data_[i]).
329 +     * @param v1 the first vector            
330 +     * @param v2 the second vector
331 +     */
332 +    inline void Vdiv( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2) {
333 +      for (unsigned int i = 0; i < Dim; i++)
334 +        this->data_[i] = v1.data_[i] / v2.data_[i];
335      }
336  
337 +
338      /** @see #add */
339      inline Vector<Real, Dim>& operator +=( const Vector<Real, Dim>& v1 ) {
340        add(v1);
# Line 324 | Line 370 | namespace OpenMD {
370          tmp += this->data_[i];
371        return tmp;  
372      }
373 +
374 +    /**
375 +     * Returns the product of all elements of this vector.
376 +     * @return the product of all elements of this vector
377 +     */
378 +    inline Real componentProduct() {
379 +      Real tmp;
380 +      tmp = 1;
381 +      for (unsigned int i = 0; i < Dim; i++)
382 +        tmp *= this->data_[i];
383 +      return tmp;  
384 +    }
385              
386      /**
387       * Returns the length of this vector.
# Line 458 | Line 516 | namespace OpenMD {
516      return tmp;
517    }
518  
519 +
520 +  
521 +
522    /**
523 +   * Returns the wide dot product of three Vectors.  Compare with
524 +   * Rapaport's VWDot function.
525 +   *
526 +   * @param v1 first vector
527 +   * @param v2 second vector
528 +   * @param v3 third vector
529 +   * @return the wide dot product of v1, v2, and v3.
530 +   */
531 +  template<typename Real, unsigned int Dim>    
532 +  inline Real dot( const Vector<Real, Dim>& v1, const Vector<Real, Dim>& v2, const Vector<Real, Dim>& v3 ) {
533 +    Real tmp;
534 +    tmp = 0;
535 +
536 +    for (unsigned int i = 0; i < Dim; i++)
537 +      tmp += v1[i] * v2[i] * v3[i];
538 +
539 +    return tmp;
540 +  }
541 +
542 +
543 +  /**
544     * Returns the distance between  two Vectors
545     * @param v1 first vector
546     * @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.
branches/development/src/math/Vector.hpp (property svn:keywords), Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines