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 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 1349 by cli2, Wed May 20 19:35:05 2009 UTC

# Line 53 | Line 53
53   #include <cmath>
54   #include <iostream>
55   #include <math.h>
56 + #include "config.h"
57   namespace oopse {
58  
59 <  static const double epsilon = 0.000001;
59 >  static const RealType epsilon = 0.000001;
60  
61    template<typename T>
62    inline bool equal(T e1, T e2) {
63      return e1 == e2;
64    }
65  
66 <  template<>
67 <  inline bool equal(float e1, float e2) {
68 <    return fabs(e1 - e2) < epsilon;
69 <  }
66 >  //template<>
67 >  //inline bool equal(float e1, float e2) {
68 >  //  return fabs(e1 - e2) < epsilon;
69 >  //}
70  
71    template<>
72 <  inline bool equal(double e1, double e2) {
72 >  inline bool equal(RealType e1, RealType e2) {
73      return fabs(e1 - e2) < epsilon;
74    }
75  
# Line 312 | Line 313 | namespace oopse {
313        return *this;
314      }
315  
316 +    /**
317 +     * Returns the sum of all elements of this vector.
318 +     * @return the sum of all elements of this vector
319 +     */
320 +    inline Real sum() {
321 +      Real tmp;
322 +      tmp = 0;
323 +      for (unsigned int i = 0; i < Dim; i++)
324 +        tmp += this->data_[i];
325 +      return tmp;  
326 +    }
327 +            
328      /**
329       * Returns the length of this vector.
330       * @return the length of this vector
# Line 345 | Line 358 | namespace oopse {
358       * @return true if this vector is normalized, otherwise return false
359       */
360      inline bool isNormalized() {
361 <      return equal(lengthSquare(), 1.0);
361 >      return equal(lengthSquare(), (RealType)1);
362      }          
363 <            
363 >
364 >    unsigned int size() {return Dim;}
365    protected:
366      Real data_[Dim];
367          

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines