29 inline double clamp(
double value,
double lower,
double upper)
31 return std::max(lower, std::min(value, upper));
38 inline void clampInPlace(
double & value,
double lower,
double upper)
40 value =
clamp(value, lower, upper);
49 inline double clampAndWarn(
double value,
double lower,
double upper,
const std::string & label)
57 else if(value < lower)
62 else {
return value; }
69 inline void clampInPlaceAndWarn(
double & value,
double lower,
double upper,
const std::string & label)
88 template<
typename VectorT>
89 inline VectorT
clamp(
const VectorT & v,
double lower,
double upper)
91 VectorT result(v.size());
92 for(
unsigned i = 0; i < v.size(); i++) { result(i) =
clamp(v(i), lower, upper); }
102 template<
typename VectorT>
103 inline VectorT
clamp(
const VectorT & v,
const VectorT & lower,
const VectorT & upper)
105 VectorT result(v.size());
106 for(
unsigned i = 0; i < v.size(); i++) { result(i) =
clamp(v(i), lower(i), upper(i)); }
116 template<
typename VectorT>
117 inline VectorT
clampAndWarn(
const VectorT & v,
const VectorT & lower,
const VectorT & upper,
const std::string & label)
119 VectorT result(v.size());
120 for(
unsigned i = 0; i < v.size(); i++)
132 template<
typename VectorT>
133 inline void clampInPlace(VectorT & v,
const VectorT & lower,
const VectorT & upper)
135 for(
unsigned i = 0; i < v.size(); i++) { v(i) =
clamp(v(i), lower(i), upper(i)); }
143 template<
typename VectorT>
146 for(
unsigned i = 0; i < v.size(); i++) { v(i) =
clamp(v(i), lower, upper); }
155 template<
typename VectorT>
158 for(
unsigned i = 0; i < vector.size(); i++)
170 template<
typename VectorT>
172 const VectorT & lower,
173 const VectorT & upper,
174 const std::string & label)
176 for(
unsigned i = 0; i < vector.size(); i++)