diff options
-rw-r--r-- | matrix.c | 2 | ||||
-rw-r--r-- | utils.h | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -247,7 +247,7 @@ int matrix_eq(const Matrix *A, const Matrix *B, const double tol) for (size_t i = 0; i < A->m; ++i) { for (size_t j = 0; j < A->n; ++j) - if (matrix_at(A, i, j) - matrix_at(B, i, j) > tol) return FALSE; + if (ABS(matrix_at(A, i, j) - matrix_at(B, i, j)) > tol) return FALSE; } return TRUE; } @@ -1,6 +1,8 @@ #ifndef UTIL_H #define UTIL_H +#define ABS(x) ((x) >= 0 ? (x) : -(x)) + char *str_delete_at(const char *str, const int pos); size_t str_count_occ(const char *str, const char ch); |