11 #ifndef MLPACK_CORE_MATH_CLAMP_HPP 12 #define MLPACK_CORE_MATH_CLAMP_HPP 30 return (d + fabs(d)) / 2;
42 return (d - fabs(d)) / 2;
54 const double rangeMin,
55 const double rangeMax)
67 #endif // MLPACK_CORE_MATH_CLAMP_HPP double ClampNonNegative(const double d)
Forces a number to be non-negative, turning negative numbers into zero.
Linear algebra utility functions, generally performed on matrices or vectors.
double ClampNonPositive(const double d)
Forces a number to be non-positive, turning positive numbers into zero.
double ClampRange(double value, const double rangeMin, const double rangeMax)
Clamp a number between a particular range.