Skip to content

Commit

Permalink
small changes to purify when dealing with subnormals (should not chan…
Browse files Browse the repository at this point in the history
…ge results)
  • Loading branch information
paulbkoch committed Dec 24, 2024
1 parent 4094054 commit 43e3711
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions shared/libebm/Purify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ extern ErrorEbm PurifyInternal(const double tolerance,
const double* pWeightRetry = aWeights;
do {
const double weight = *pWeightRetry;
EBM_ASSERT(!std::isnan(weight) && (0.0 == weight || std::numeric_limits<double>::min() <= weight) &&
weight != std::numeric_limits<double>::infinity());
EBM_ASSERT(!std::isnan(weight) && 0.0 <= weight && weight != std::numeric_limits<double>::infinity());
const double score = *IndexByte(pScores, iScoreRetry);
if(!std::isnan(score) && !std::isinf(score)) {
double weightTimesFactor = factorPre * weight;
Expand Down Expand Up @@ -1014,12 +1013,14 @@ extern ErrorEbm PurifyInternal(const double tolerance,
}

double newIntercept = *pIntercept;
if(-std::numeric_limits<double>::min() < newIntercept &&
newIntercept < std::numeric_limits<double>::min()) {
// eliminate denormals
newIntercept = 0.0;
}
EBM_ASSERT(!std::isnan(newIntercept)); // we never write NaN
EBM_ASSERT(!std::isinf(newIntercept)); // we never write inf

// *pIntercept started off as zero and we haven't written a denormal
EBM_ASSERT(0.0 == newIntercept || newIntercept <= -std::numeric_limits<double>::min() ||
std::numeric_limits<double>::min() <= newIntercept);
newIntercept += interceptChange;
EBM_ASSERT(!std::isnan(newIntercept));
if(-std::numeric_limits<double>::min() < newIntercept &&
newIntercept < std::numeric_limits<double>::min()) {
// eliminate denormals
Expand Down

0 comments on commit 43e3711

Please sign in to comment.