From bac6f93a2dcb0e3ab4cfbe8beb174ede34e6838b Mon Sep 17 00:00:00 2001 From: Johan Larsson Date: Tue, 6 Feb 2024 14:13:49 +0100 Subject: [PATCH] fix(deps): update to libslope 0.3.1 --- src/slope/constants.h | 8 ++++++++ src/slope/slope.h | 5 +++-- src/slope/slope_threshold.cpp | 1 - 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/slope/constants.h diff --git a/src/slope/constants.h b/src/slope/constants.h new file mode 100644 index 0000000..23da389 --- /dev/null +++ b/src/slope/constants.h @@ -0,0 +1,8 @@ +/** + * @internal + * @file + * @brief Definitions of constants used in libslope + */ +#pragma once + +const double EPSILON = 1e-10; diff --git a/src/slope/slope.h b/src/slope/slope.h index 5a70d6d..29d4ff1 100644 --- a/src/slope/slope.h +++ b/src/slope/slope.h @@ -7,6 +7,7 @@ #include "cd.h" #include "clusters.h" +#include "constants.h" #include "helpers.h" #include "math.h" #include "objectives.h" @@ -390,7 +391,7 @@ class Slope dual_gaps.emplace_back(dual_gap); - double tol_scaled = std::abs(primal) * this->tol; + double tol_scaled = (std::abs(primal) + EPSILON) * this->tol; if (this->print_level > 1) { std::cout << indent(1) << "IRLS iteration: " << it_outer << std::endl @@ -431,7 +432,7 @@ class Slope double dual_gap_inner = primal_inner - dual_inner; - double tol_inner = std::abs(primal_inner) * this->tol; + double tol_inner = (std::abs(primal_inner) + EPSILON) * this->tol; if (this->print_level > 2) { std::cout << indent(2) << "iteration: " << it << std::endl diff --git a/src/slope/slope_threshold.cpp b/src/slope/slope_threshold.cpp index 7cc4f78..f2b86bb 100644 --- a/src/slope/slope_threshold.cpp +++ b/src/slope/slope_threshold.cpp @@ -42,7 +42,6 @@ slopeThreshold(const double x, } return { x - sign_x * lo, 0 }; - } else { int end = clusters.pointer(j + 1); double hi = lambdas.segment(end - cluster_size, cluster_size).sum();