From 8f53f6a35ca0f80bc9a40106dcfe0c79cbb636c8 Mon Sep 17 00:00:00 2001 From: Petr Sabanov Date: Tue, 1 Apr 2025 15:27:52 +0300 Subject: [PATCH] Refined epsilon handling: consider boundary values as equal - Changed epsilon comparisons from "<" to "<=" so values exactly at epsilon are treated as equal. - Updated the `tests/test_data` submodule to commit with similar changes. --- ALFI/ALFI/util/linalg.h | 2 +- ALFI/ALFI/util/numeric.h | 2 +- tests/test_data | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ALFI/ALFI/util/linalg.h b/ALFI/ALFI/util/linalg.h index 01bdda7..522c0e0 100644 --- a/ALFI/ALFI/util/linalg.h +++ b/ALFI/ALFI/util/linalg.h @@ -45,7 +45,7 @@ namespace alfi::util::linalg { i_max = k; } } - if (max_a < epsilon) { + if (max_a <= epsilon) { std::cerr << "Error in function " << __FUNCTION__ << ": Matrix A is degenerate. Returning an empty array..." << std::endl; return {}; } diff --git a/ALFI/ALFI/util/numeric.h b/ALFI/ALFI/util/numeric.h index 137670d..24b5965 100644 --- a/ALFI/ALFI/util/numeric.h +++ b/ALFI/ALFI/util/numeric.h @@ -7,6 +7,6 @@ namespace alfi::util::numeric { template bool are_equal(Number a, Number b, Number epsilon = std::numeric_limits::epsilon()) { - return std::abs(a - b) < epsilon || std::abs(a - b) < std::max(std::abs(a), std::abs(b)) * epsilon; + return std::abs(a - b) <= epsilon || std::abs(a - b) <= std::max(std::abs(a), std::abs(b)) * epsilon; } } \ No newline at end of file diff --git a/tests/test_data b/tests/test_data index 167bd0f..638f783 160000 --- a/tests/test_data +++ b/tests/test_data @@ -1 +1 @@ -Subproject commit 167bd0f1f95372d5770ecf577c852a381b45b98d +Subproject commit 638f783565d9df83e543e37e0ca5340c331c60b2