| 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). | 
| 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 |  | */ | 
| 49 |  |  | 
| 50 |  | namespace OpenMD { | 
| 51 |  |  | 
| 52 | + |  | 
| 53 | + | class BaseAccumulator { | 
| 54 | + | public: | 
| 55 | + | virtual void clear() = 0; | 
| 56 | + | /** | 
| 57 | + | * get the number of accumulated values | 
| 58 | + | */ | 
| 59 | + | virtual size_t count()  { | 
| 60 | + | return Count_; | 
| 61 | + | } | 
| 62 | + | protected: | 
| 63 | + | size_t Count_; | 
| 64 | + |  | 
| 65 | + | }; | 
| 66 | + |  | 
| 67 | + |  | 
| 68 | + |  | 
| 69 |  | /** | 
| 70 |  | * Basic Accumulator class for numbers. | 
| 71 | < | */ | 
| 72 | < |  | 
| 56 | < | class Accumulator { | 
| 71 | > | */ | 
| 72 | > | class Accumulator : public BaseAccumulator { | 
| 73 |  |  | 
| 74 |  | typedef RealType ElementType; | 
| 75 |  | typedef RealType ResultType; | 
| 76 |  |  | 
| 77 |  | public: | 
| 78 |  |  | 
| 79 | < | Accumulator() { | 
| 79 | > | Accumulator() : BaseAccumulator() { | 
| 80 |  | this->clear(); | 
| 81 |  | } | 
| 82 |  |  | 
| 107 |  | Val_   = 0; | 
| 108 |  | } | 
| 109 |  |  | 
| 94 | – | /** | 
| 95 | – | * get the number of accumulated values | 
| 96 | – | */ | 
| 97 | – | size_t count()  { | 
| 98 | – | return Count_; | 
| 99 | – | } | 
| 110 |  |  | 
| 111 |  | /** | 
| 112 |  | * return the most recently added value | 
| 163 |  | return; | 
| 164 |  | } | 
| 165 |  |  | 
| 156 | – | protected: | 
| 157 | – | size_t Count_; | 
| 166 |  | private: | 
| 167 |  | ElementType Val_; | 
| 168 |  | ResultType Avg_; | 
| 171 |  | ElementType Max_; | 
| 172 |  | }; | 
| 173 |  |  | 
| 174 | < | class VectorAccumulator : public Accumulator { | 
| 174 | > | class VectorAccumulator : public BaseAccumulator { | 
| 175 |  |  | 
| 176 |  | typedef Vector3d ElementType; | 
| 177 |  | typedef Vector3d ResultType; | 
| 178 |  |  | 
| 179 |  | public: | 
| 180 | < | VectorAccumulator() : Accumulator() { | 
| 180 | > | VectorAccumulator() : BaseAccumulator() { | 
| 181 |  | this->clear(); | 
| 182 |  | } | 
| 183 |  |  | 
| 305 |  | ret = sqrt(var); | 
| 306 |  | return; | 
| 307 |  | } | 
| 308 | < |  | 
| 301 | < | protected: | 
| 302 | < | size_t Count_; | 
| 308 | > |  | 
| 309 |  | private: | 
| 310 |  | ResultType Val_; | 
| 311 |  | ResultType Avg_; | 
| 317 |  |  | 
| 318 |  | }; | 
| 319 |  |  | 
| 320 | < | class MatrixAccumulator : public Accumulator { | 
| 320 | > | class MatrixAccumulator : public BaseAccumulator { | 
| 321 |  |  | 
| 322 |  | typedef Mat3x3d ElementType; | 
| 323 |  | typedef Mat3x3d ResultType; | 
| 324 |  |  | 
| 325 |  | public: | 
| 326 | < | MatrixAccumulator() : Accumulator() { | 
| 326 | > | MatrixAccumulator() : BaseAccumulator() { | 
| 327 |  | this->clear(); | 
| 328 |  | } | 
| 329 |  |  | 
| 396 |  | return; | 
| 397 |  | } | 
| 398 |  |  | 
| 393 | – | protected: | 
| 394 | – | size_t Count_; | 
| 399 |  | private: | 
| 400 |  | ElementType Val_; | 
| 401 |  | ResultType Avg_; |