Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
add braces around statements and cleanup formatting (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored and Julian Kent committed Nov 13, 2019
1 parent 38e966c commit cd185c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions matrix/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,13 @@ 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
if(x_is_nan || y_is_nan) {
if(x_is_nan && !y_is_nan) return y;
if(!x_is_nan && y_is_nan) return x;
if (x_is_nan || y_is_nan) {
if (x_is_nan && !y_is_nan) {
return y;
}
if (!x_is_nan && y_is_nan) {
return x;
}
return x;
}
return (x < y) ? x : y;
Expand All @@ -599,16 +603,20 @@ 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
if(x_is_nan || y_is_nan) {
if(x_is_nan && !y_is_nan) return y;
if(!x_is_nan && y_is_nan) return x;
if (x_is_nan || y_is_nan) {
if (x_is_nan && !y_is_nan) {
return y;
}
if (!x_is_nan && y_is_nan) {
return x;
}
return x;
}
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) {
if (lower_bound > upper_bound) {
return NAN;
} else if(isnan(x)) {
return NAN;
Expand Down Expand Up @@ -677,7 +685,7 @@ Matrix<Type, M, N> constrain(const Matrix<Type, M, N> &x,
const Type scalar_lower_bound,
const Type scalar_upper_bound) {
Matrix<Type,M,N> m;
if(scalar_lower_bound > scalar_upper_bound) {
if (scalar_lower_bound > scalar_upper_bound) {
m.setNaN();
} else {
for (size_t i = 0; i < M; i++) {
Expand Down
4 changes: 2 additions & 2 deletions matrix/SquareMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SquareMatrix : public Matrix<Type, M, M>
inline SquareMatrix<Type, M> I() const
{
SquareMatrix<Type, M> i;
if(inv(*this, i)) {
if (inv(*this, i)) {
return i;
} else {
i.setZero();
Expand Down Expand Up @@ -289,7 +289,7 @@ template<typename Type, size_t M>
SquareMatrix<Type, M> inv(const SquareMatrix<Type, M> & A)
{
SquareMatrix<Type, M> i;
if(inv(A, i)) {
if (inv(A, i)) {
return i;
} else {
i.setZero();
Expand Down

0 comments on commit cd185c9

Please sign in to comment.