Matrix: min max comments and test style

This commit is contained in:
Matthias Grob
2020-03-23 09:46:07 +01:00
committed by Julian Kent
parent fa7153ecfb
commit 976ada411b
2 changed files with 16 additions and 14 deletions
+4 -2
View File
@@ -615,7 +615,7 @@ template<typename Type>
Type min(const Type x, const Type y) {
bool x_is_nan = isnan(x);
bool y_is_nan = isnan(y);
// z > nan for z != nan is required by C the standard
// take the non-nan value if there is one
if (x_is_nan || y_is_nan) {
if (x_is_nan && !y_is_nan) {
return y;
@@ -625,11 +625,12 @@ Type min(const Type x, const Type y) {
}
return (x < y) ? x : y;
}
template<typename Type>
Type max(const Type x, const Type y) {
bool x_is_nan = isnan(x);
bool y_is_nan = isnan(y);
// z > nan for z != nan is required by C the standard
// take the non-nan value if there is one
if (x_is_nan || y_is_nan) {
if (x_is_nan && !y_is_nan) {
return y;
@@ -639,6 +640,7 @@ Type max(const Type x, const Type y) {
}
return (x > y) ? x : y;
}
template<typename Type>
Type constrain(const Type x, const Type lower_bound, const Type upper_bound) {
if (lower_bound > upper_bound) {