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 1615 by gezelter, Fri Aug 26 17:55:44 2011 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

# Line 35 | Line 35
35   *                                                                      
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).                        
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
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 107 | Line 107 | namespace OpenMD {
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 */            
# Line 195 | Line 196 | namespace OpenMD {
196      inline bool operator !=(const Vector<Real, Dim>& v) {
197        return !(*this == v);
198      }
199 +
200 +    /** Zeros out the values in this vector in place */
201 +    inline void zero() {
202 +      for (unsigned int i = 0; i < Dim; i++)
203 +        this->data_[i] = 0;
204 +    }      
205              
206      /** Negates the value of this vector in place. */          
207      inline void negate() {
# Line 284 | Line 291 | namespace OpenMD {
291          this->data_[i] = v1.data_[i] * v2.data_[i];
292      }
293  
294 +    /* replaces the elements with the absolute values of those elements */
295 +    inline Vector<Real, Dim>& abs() {
296 +      for (unsigned int i = 0; i < Dim; i++) {
297 +        this->data_[i] = std::abs(this->data_[i]);
298 +      }
299 +      return *this;
300 +    }
301 +    
302 +    /* returns the maximum value in this vector */
303 +    inline Real max() {
304 +      Real val = this->data_[0];
305 +      for (unsigned int i = 0; i < Dim; i++) {
306 +        if (this->data_[i] > val) val = this->data_[i];
307 +      }
308 +      return val;
309 +    }
310 +    
311      /**
312       * Sets the value of this vector to the scalar division of itself  (*this /= s ).
313       * @param s the scalar value

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines