6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
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, 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 |
|
/** |
57 |
|
#include <algorithm> |
58 |
|
#include <vector> |
59 |
|
|
60 |
< |
namespace oopse { |
60 |
> |
namespace OpenMD { |
61 |
|
|
62 |
|
/** |
63 |
|
* @class DynamicVector DynamicVector.hpp "math/DynamicVector.hpp" |
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 |
|
*/ |
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 |
|
} |
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 |
303 |
|
|
304 |
|
len = length(); |
305 |
|
|
306 |
< |
//if (len < oopse:epsilon) |
306 |
> |
//if (len < OpenMD::NumericConstant::epsilon) |
307 |
|
// throw(); |
308 |
|
|
309 |
|
*this /= len; |
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 |
|
} |
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 |
|
} |
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 |
|
} |
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 |
|
} |
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 |
|
} |