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

Comparing:
trunk/src/math/DynamicVector.hpp (file contents), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/math/DynamicVector.hpp (file contents), Revision 1808 by gezelter, Mon Oct 22 20:42:10 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 93 | Line 94 | namespace OpenMD {
94         *  @brief  Create a %DynamicVector with copies of an exemplar element.
95         *  @param  n  The number of elements to initially create.
96         *  @param  value  An element to copy.
97 +       *  @param  alloc  The allocator_type to use
98         *
99         *  This constructor fills the %DynamicVector with @a n copies of @a value.
100         */
# Line 225 | Line 227 | namespace OpenMD {
227       * @param s the scalar value
228       */
229      inline void mul( const DynamicVector<Real>& v1, Real s) {
230 +      this->resize(v1.size());
231        for (unsigned int i = 0; i < this->size(); i++)
232          (*this)[i] = s * v1[i];
233      }
# Line 272 | Line 275 | namespace OpenMD {
275        return *this;
276      }
277  
278 +    /** zero out the vector */
279 +    inline void setZero( ) {
280 +      for (unsigned int i = 0; i < this->size(); i++)
281 +        (*this)[i] = 0;
282 +    }
283 +
284      /**
285       * Returns the length of this vector.
286       * @return the length of this vector
# Line 335 | Line 344 | namespace OpenMD {
344     */  
345    template<typename Real>    
346    inline DynamicVector<Real> operator +(const DynamicVector<Real>& v1, const DynamicVector<Real>& v2) {
347 <    DynamicVector<Real> result;
348 <        
347 >    assert(v1.size() == v2.size());
348 >    DynamicVector<Real>result(v1.size());
349      result.add(v1, v2);
350      return result;        
351    }
# Line 349 | Line 358 | namespace OpenMD {
358     */  
359    template<typename Real>    
360    DynamicVector<Real> operator -(const DynamicVector<Real>& v1, const DynamicVector<Real>& v2) {
361 <    DynamicVector<Real> result;
361 >    assert(v1.size() == v2.size());
362 >    DynamicVector<Real> result(v1.size());
363      result.sub(v1, v2);
364      return result;        
365    }
# Line 361 | Line 371 | namespace OpenMD {
371     * @param s the scalar value
372     */
373    template<typename Real>                
374 <  DynamicVector<Real> operator * ( const DynamicVector<Real>& v1, Real s) {      
375 <    DynamicVector<Real> result;
374 >  DynamicVector<Real> operator *( const DynamicVector<Real>& v1, Real s) {      
375 >    DynamicVector<Real> result(v1.size());
376      result.mul(v1,s);
377      return result;          
378    }
# Line 374 | Line 384 | namespace OpenMD {
384     * @param v1 the source vector
385     */  
386    template<typename Real>
387 <  DynamicVector<Real> operator * ( Real s, const DynamicVector<Real>& v1 ) {
388 <    DynamicVector<Real> result;
387 >  DynamicVector<Real> operator *( Real s, const DynamicVector<Real>& v1 ) {
388 >    DynamicVector<Real> result(v1.size());
389      result.mul(v1, s);
390      return result;          
391    }
# Line 387 | Line 397 | namespace OpenMD {
397     * @param s the scalar value
398     */
399    template<typename Real>    
400 <  DynamicVector<Real> operator / ( const DynamicVector<Real>& v1, Real s) {      
401 <    DynamicVector<Real> result;
400 >  DynamicVector<Real> operator / ( const DynamicVector<Real>& v1, Real s) {    
401 >    DynamicVector<Real> result(v1.size());
402      result.div( v1,s);
403      return result;          
404    }

Comparing:
trunk/src/math/DynamicVector.hpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/development/src/math/DynamicVector.hpp (property svn:keywords), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines