From 14ce6711ebaed5da701fb47595e78d4c9ee72f59 Mon Sep 17 00:00:00 2001 From: Diederik de Groot Date: Mon, 7 May 2018 15:39:48 +0200 Subject: [PATCH 1/2] Backport logGamma fix using slightly less accuracy for DragonFlyBSD See [ltsmaster-phobos PR:45](https://github.com/ldc-developers/phobos/pull/45#discussion_r159118875) --- std/internal/math/gammafunction.d | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/std/internal/math/gammafunction.d b/std/internal/math/gammafunction.d index ec403193e4e..55f341aa24b 100644 --- a/std/internal/math/gammafunction.d +++ b/std/internal/math/gammafunction.d @@ -566,8 +566,14 @@ real logGamma(real x) assert( feqrel(log(fabs(gamma(testpoints[i]))), testpoints[i+1]) > real.mant_dig-5); } } - assert(logGamma(-50.2) == log(fabs(gamma(-50.2)))); - assert(logGamma(-0.008) == log(fabs(gamma(-0.008)))); + version (DragonFlyBSD) { // FIXME: DragonFlyBSD: rounding differences between logGamma() and log() (ie:llvm_log()) + // Maybe we should be using lgamma or tgamma instead of gamma (ISO Standard N1570). + assert(feqrel(logGamma(-50.2),log(fabs(gamma(-50.2)))) > real.mant_dig-2); + assert(feqrel(logGamma(-0.008),log(fabs(gamma(-0.008)))) > real.mant_dig-2); + } else { + assert(logGamma(-50.2) == log(fabs(gamma(-50.2)))); + assert(logGamma(-0.008) == log(fabs(gamma(-0.008)))); + } assert(feqrel(logGamma(-38.8),log(fabs(gamma(-38.8)))) > real.mant_dig-4); static if (real.mant_dig >= 64) // incl. 80-bit reals assert(feqrel(logGamma(1500.0L),log(gamma(1500.0L))) > real.mant_dig-2); From 1d1f41ce32482eeb94e8edb5298e40db5da750e7 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 12 May 2018 19:43:58 +0200 Subject: [PATCH 2/2] Update gammafunction.d --- std/internal/math/gammafunction.d | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/std/internal/math/gammafunction.d b/std/internal/math/gammafunction.d index 55f341aa24b..a33d98b0b02 100644 --- a/std/internal/math/gammafunction.d +++ b/std/internal/math/gammafunction.d @@ -566,14 +566,8 @@ real logGamma(real x) assert( feqrel(log(fabs(gamma(testpoints[i]))), testpoints[i+1]) > real.mant_dig-5); } } - version (DragonFlyBSD) { // FIXME: DragonFlyBSD: rounding differences between logGamma() and log() (ie:llvm_log()) - // Maybe we should be using lgamma or tgamma instead of gamma (ISO Standard N1570). - assert(feqrel(logGamma(-50.2),log(fabs(gamma(-50.2)))) > real.mant_dig-2); - assert(feqrel(logGamma(-0.008),log(fabs(gamma(-0.008)))) > real.mant_dig-2); - } else { - assert(logGamma(-50.2) == log(fabs(gamma(-50.2)))); - assert(logGamma(-0.008) == log(fabs(gamma(-0.008)))); - } + assert(feqrel(logGamma(-50.2),log(fabs(gamma(-50.2)))) > real.mant_dig-2); + assert(feqrel(logGamma(-0.008),log(fabs(gamma(-0.008)))) > real.mant_dig-2); assert(feqrel(logGamma(-38.8),log(fabs(gamma(-38.8)))) > real.mant_dig-4); static if (real.mant_dig >= 64) // incl. 80-bit reals assert(feqrel(logGamma(1500.0L),log(gamma(1500.0L))) > real.mant_dig-2);