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

Comparing branches/development/src/math/Vector.hpp (file contents):
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1767 by gezelter, Fri Jul 6 22:01:58 2012 UTC

# Line 73 | Line 73 | namespace OpenMD {
73    inline bool equal(RealType e1, RealType e2) {
74      return fabs(e1 - e2) < epsilon;
75    }
76
76      
77    /**
78     * @class Vector Vector.hpp "math/Vector.hpp"
# Line 108 | 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 285 | Line 285 | namespace OpenMD {
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines