| 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 |
|
|
| 319 |
|
|
| 320 |
|
}; |
| 321 |
|
|
| 322 |
< |
class MatrixAccumulator : public Accumulator { |
| 322 |
> |
class MatrixAccumulator : public BaseAccumulator { |
| 323 |
|
|
| 324 |
|
typedef Mat3x3d ElementType; |
| 325 |
|
typedef Mat3x3d ResultType; |
| 326 |
|
|
| 327 |
|
public: |
| 328 |
< |
MatrixAccumulator() : Accumulator() { |
| 328 |
> |
MatrixAccumulator() : BaseAccumulator() { |
| 329 |
|
this->clear(); |
| 330 |
|
} |
| 331 |
|
|