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

Commit

Permalink
Matrix: fix warning if M == N (#146)
Browse files Browse the repository at this point in the history
This fixes the warning appearing with GCC 10.2:

../../src/lib/matrix/matrix/Matrix.hpp:481:34: error: logical ‘and’ of equal expressions [-Werror=logical-op]
  481 |         for (size_t i = 0; i < M && i < N; i++) {
      |

I would prefered something with if constexpr but we don't have that yet
in because we're using C++14.
  • Loading branch information
julianoes authored Aug 24, 2020
1 parent cd8ad15 commit e101edc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion matrix/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ class Matrix
setZero();
Matrix<Type, M, N> &self = *this;

for (size_t i = 0; i < M && i < N; i++) {
const size_t min_i = M > N ? N : M;
for (size_t i = 0; i < min_i; i++) {
self(i, i) = 1;
}
}
Expand Down

0 comments on commit e101edc

Please sign in to comment.