Template Function GridKit::Math::clamp
Defined in File CommonMath.hpp
Function Documentation
-
template<class ScalarT, typename LowerT, typename UpperT>
inline auto GridKit::Math::clamp(const ScalarT x, const LowerT lower, const UpperT upper) Smooth clamp function.
Smooth approximation to min(max(x, lower), upper), composed from the smooth ramp function. Lower and upper bounds may be independent types (e.g. constant Real bounds or algebraic-variable bounds).
- Template Parameters:
ScalarT – - scalar data type of the input signal
LowerT – - data type of the lower bound
UpperT – - data type of the upper bound
- Parameters:
x – [in] - expected to be of order 1
lower – [in] - Lower limit
upper – [in] - Upper limit
- Returns:
value of the smooth clamp function