statistic helper classes
test-cases modified grid importance for better trap-detection
This commit is contained in:
40
math/stats/Minimum.h
Normal file
40
math/stats/Minimum.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef STATS_MINIMUM_H
|
||||
#define STATS_MINIMUM_H
|
||||
|
||||
namespace Stats {
|
||||
|
||||
template <typename Scalar> class Minimum {
|
||||
|
||||
private:
|
||||
|
||||
const Scalar START = +999999999;
|
||||
Scalar curMin;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
Minimum() : curMin(START) {
|
||||
;
|
||||
}
|
||||
|
||||
/** is a valid minimum available? */
|
||||
inline bool isValid() const {
|
||||
return curMin != START;
|
||||
}
|
||||
|
||||
/** add a new value */
|
||||
void add(const Scalar val) {
|
||||
if (val < curMin) {curMin = val;}
|
||||
}
|
||||
|
||||
/** get the current value */
|
||||
Scalar get() const {
|
||||
Assert::notEqual(curMin, START, "add() values first!");
|
||||
return curMin;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // STATS_MINIMUM_H
|
||||
Reference in New Issue
Block a user