Skip to content

Commit

Permalink
Remove asserts for unsigned integer >= 0
Browse files Browse the repository at this point in the history
GCC 10 gives a warning
"comparison of unsigned expression in ‘>= 0’ is always true"
for these asserts since checking if an unsigned integer cannot
be negative and hence the statement gets droped.
  • Loading branch information
MaEtUgR authored and jkflying committed Jul 20, 2020
1 parent 0fd99c5 commit 7a3009f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 23 deletions.
8 changes: 0 additions & 8 deletions matrix/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,15 @@ class Matrix

inline const Type &operator()(size_t i, size_t j) const
{
assert(i >= 0);
assert(i < M);
assert(j >= 0);
assert(j < N);

return _data[i][j];
}

inline Type &operator()(size_t i, size_t j)
{
assert(i >= 0);
assert(i < M);
assert(j >= 0);
assert(j < N);

return _data[i][j];
Expand Down Expand Up @@ -494,9 +490,7 @@ class Matrix

inline void swapRows(size_t a, size_t b)
{
assert(a >= 0);
assert(a < M);
assert(b >= 0);
assert(b < M);

if (a == b) {
Expand All @@ -514,9 +508,7 @@ class Matrix

inline void swapCols(size_t a, size_t b)
{
assert(a >= 0);
assert(a < N);
assert(b >= 0);
assert(b < N);

if (a == b) {
Expand Down
6 changes: 0 additions & 6 deletions matrix/Slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ class Slice {
_data(const_cast<Matrix<Type, M, N>*>(data)) {
static_assert(P <= M, "Slice rows bigger than backing matrix");
static_assert(Q <= N, "Slice cols bigger than backing matrix");
assert(x0 >= 0);
assert(x0 + P <= M);
assert(y0 >= 0);
assert(y0 + Q <= N);
}

const Type &operator()(size_t i, size_t j) const
{
assert(i >= 0);
assert(i < P);
assert(j >= 0);
assert(j < Q);

return (*_data)(_x0 + i, _y0 + j);
Expand All @@ -47,9 +43,7 @@ class Slice {
Type &operator()(size_t i, size_t j)

{
assert(i >= 0);
assert(i < P);
assert(j >= 0);
assert(j < Q);

return (*_data)(_x0 + i, _y0 + j);
Expand Down
7 changes: 0 additions & 7 deletions matrix/SquareMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class SquareMatrix : public Matrix<Type, M, M>
void uncorrelateCovariance(size_t first)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -148,7 +147,6 @@ class SquareMatrix : public Matrix<Type, M, M>
void uncorrelateCovarianceSetVariance(size_t first, const Vector<Type, Width> &vec)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -168,7 +166,6 @@ class SquareMatrix : public Matrix<Type, M, M>
void uncorrelateCovarianceSetVariance(size_t first, Type val)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -187,7 +184,6 @@ class SquareMatrix : public Matrix<Type, M, M>
void makeBlockSymmetric(size_t first)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -207,7 +203,6 @@ class SquareMatrix : public Matrix<Type, M, M>
void makeRowColSymmetric(size_t first)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -231,7 +226,6 @@ class SquareMatrix : public Matrix<Type, M, M>
bool isBlockSymmetric(size_t first, const Type eps = 1e-8f)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand All @@ -252,7 +246,6 @@ class SquareMatrix : public Matrix<Type, M, M>
bool isRowColSymmetric(size_t first, const Type eps = 1e-8f)
{
static_assert(Width <= M, "Width bigger than matrix");
assert(first >= 0);
assert(first + Width <= M);

SquareMatrix<Type, M> &self = *this;
Expand Down
2 changes: 0 additions & 2 deletions matrix/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Vector : public Matrix<Type, M, 1>

inline const Type &operator()(size_t i) const
{
assert(i >= 0);
assert(i < M);

const MatrixM1 &v = *this;
Expand All @@ -51,7 +50,6 @@ class Vector : public Matrix<Type, M, 1>

inline Type &operator()(size_t i)
{
assert(i >= 0);
assert(i < M);

MatrixM1 &v = *this;
Expand Down

0 comments on commit 7a3009f

Please sign in to comment.