Skip to content

Commit 65e380c

Browse files
ibuclawdlang-bot
authored andcommitted
std.math.exponential: Fix wrong placement of 1.0 in log1p coefficient
1 parent ab09084 commit 65e380c

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

std/math/exponential.d

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,13 +3033,13 @@ private
30333033
4.5270000862445199635215E-5,
30343034
];
30353035
static immutable double[7] logp1Q = [
3036-
1.0000000000000000000000E0,
30373036
6.0118660497603843919306E1,
30383037
2.1642788614495947685003E2,
30393038
3.0909872225312059774938E2,
30403039
2.2176239823732856465394E2,
30413040
8.3047565967967209469434E1,
30423041
1.5062909083469192043167E1,
3042+
1.0000000000000000000000E0,
30433043
];
30443044

30453045
static immutable double[7] log10P = [
@@ -3101,13 +3101,13 @@ private
31013101
4.5270000862E-5,
31023102
];
31033103
static immutable float[7] logp1Q = [
3104-
1.00000000000E0,
31053104
6.01186604976E1,
31063105
2.16427886144E2,
31073106
3.09098722253E2,
31083107
2.21762398237E2,
31093108
8.30475659679E1,
31103109
1.50629090834E1,
3110+
1.00000000000E0,
31113111
];
31123112

31133113
// log2 and log10 uses the same coefficients as log.
@@ -3323,7 +3323,7 @@ private T logImpl(T, bool LOG1P = false)(T x) @safe pure nothrow @nogc
33233323
}
33243324
static foreach (F; AliasSeq!(float, double, real))
33253325
{{
3326-
F[2][24] vals = [
3326+
scope F[2][] vals = [
33273327
[F(1), F(0x0p+0)], [F(2), F(0x1.62e42fefa39ef358p-1)],
33283328
[F(4), F(0x1.62e42fefa39ef358p+0)], [F(8), F(0x1.0a2b23f3bab73682p+1)],
33293329
[F(16), F(0x1.62e42fefa39ef358p+1)], [F(32), F(0x1.bb9d3beb8c86b02ep+1)],
@@ -3335,6 +3335,9 @@ private T logImpl(T, bool LOG1P = false)(T x) @safe pure nothrow @nogc
33353335
[F(17), F(0x1.6aa6bc1fa7f79cfp+1)], [F(31), F(0x1.b78ce48912b59f12p+1)],
33363336
[F(33), F(0x1.bf8d8f4d5b8d1038p+1)], [F(63), F(0x1.09291e8e3181b20ep+2)],
33373337
[F(65), F(0x1.0b292939429755ap+2)], [F(-0), -F.infinity], [F(0), -F.infinity],
3338+
[F(0.1), F(-0x1.26bb1bbb5551582ep+1)], [F(0.25), F(-0x1.62e42fefa39ef358p+0)],
3339+
[F(0.75), F(-0x1.269621134db92784p-2)], [F(0.875), F(-0x1.1178e8227e47bde4p-3)],
3340+
[F(10), F(0x1.26bb1bbb5551582ep+1)], [F(100), F(0x1.26bb1bbb5551582ep+2)],
33383341
[F(10000), F(0x1.26bb1bbb5551582ep+3)],
33393342
];
33403343
testLog(vals);
@@ -3572,7 +3575,7 @@ Ldone:
35723575
}
35733576
static foreach (F; AliasSeq!(float, double, real))
35743577
{{
3575-
F[2][24] vals = [
3578+
scope F[2][] vals = [
35763579
[F(1), F(0x0p+0)], [F(2), F(0x1.34413509f79fef32p-2)],
35773580
[F(4), F(0x1.34413509f79fef32p-1)], [F(8), F(0x1.ce61cf8ef36fe6cap-1)],
35783581
[F(16), F(0x1.34413509f79fef32p+0)], [F(32), F(0x1.8151824c7587eafep+0)],
@@ -3584,7 +3587,9 @@ Ldone:
35843587
[F(17), F(0x1.3afeb354b7d9731ap+0)], [F(31), F(0x1.7dc9e145867e62eap+0)],
35853588
[F(33), F(0x1.84bd545e4baeddp+0)], [F(63), F(0x1.cca1950e4511e192p+0)],
35863589
[F(65), F(0x1.d01b16f9433cf7b8p+0)], [F(-0), -F.infinity], [F(0), -F.infinity],
3587-
[F(10000), F(0x1p+2)],
3590+
[F(0.1), F(-0x1p+0)], [F(0.25), F(-0x1.34413509f79fef32p-1)],
3591+
[F(0.75), F(-0x1.ffbfc2bbc7803758p-4)], [F(0.875), F(-0x1.db11ed766abf432ep-5)],
3592+
[F(10), F(0x1p+0)], [F(100), F(0x1p+1)], [F(10000), F(0x1p+2)],
35883593
];
35893594
testLog10(vals);
35903595
}}
@@ -3758,7 +3763,7 @@ private T log1pImpl(T)(T x) @safe pure nothrow @nogc
37583763
}
37593764
static foreach (F; AliasSeq!(float, double, real))
37603765
{{
3761-
F[2][24] vals = [
3766+
scope F[2][] vals = [
37623767
[F(1), F(0x1.62e42fefa39ef358p-1)], [F(2), F(0x1.193ea7aad030a976p+0)],
37633768
[F(4), F(0x1.9c041f7ed8d336bp+0)], [F(8), F(0x1.193ea7aad030a976p+1)],
37643769
[F(16), F(0x1.6aa6bc1fa7f79cfp+1)], [F(32), F(0x1.bf8d8f4d5b8d1038p+1)],
@@ -3770,6 +3775,9 @@ private T log1pImpl(T)(T x) @safe pure nothrow @nogc
37703775
[F(17), F(0x1.71f7b3a6b918664cp+1)], [F(31), F(0x1.bb9d3beb8c86b02ep+1)],
37713776
[F(33), F(0x1.c35fc81b90df59c6p+1)], [F(63), F(0x1.0a2b23f3bab73682p+2)],
37723777
[F(65), F(0x1.0c234da4a23a6686p+2)], [F(-0), F(-0x0p+0)], [F(0), F(0x0p+0)],
3778+
[F(0.1), F(0x1.8663f793c46c69cp-4)], [F(0.25), F(0x1.c8ff7c79a9a21ac4p-3)],
3779+
[F(0.75), F(0x1.1e85f5e7040d03ep-1)], [F(0.875), F(0x1.41d8fe84672ae646p-1)],
3780+
[F(10), F(0x1.32ee3b77f374bb7cp+1)], [F(100), F(0x1.275e2271bba30be4p+2)],
37733781
[F(10000), F(0x1.26bbed6fbd84182ep+3)],
37743782
];
37753783
testLog1p(vals);
@@ -3981,7 +3989,7 @@ Ldone:
39813989
}
39823990
static foreach (F; AliasSeq!(float, double, real))
39833991
{{
3984-
F[2][24] vals = [
3992+
scope F[2][] vals = [
39853993
[F(1), F(0x0p+0)], [F(2), F(0x1p+0)],
39863994
[F(4), F(0x1p+1)], [F(8), F(0x1.8p+1)],
39873995
[F(16), F(0x1p+2)], [F(32), F(0x1.4p+2)],
@@ -3993,6 +4001,9 @@ Ldone:
39934001
[F(17), F(0x1.0598fdbeb244c5ap+2)], [F(31), F(0x1.3d118d66c4d4e554p+2)],
39944002
[F(33), F(0x1.42d75a6eb1dfb0e6p+2)], [F(63), F(0x1.7e8bc1179e0caa9cp+2)],
39954003
[F(65), F(0x1.816e79685c2d2298p+2)], [F(-0), -F.infinity], [F(0), -F.infinity],
4004+
[F(0.1), F(-0x1.a934f0979a3715fcp+1)], [F(0.25), F(-0x1p+1)],
4005+
[F(0.75), F(-0x1.a8ff971810a5e182p-2)], [F(0.875), F(-0x1.8a8980abfbd32668p-3)],
4006+
[F(10), F(0x1.a934f0979a3715fcp+1)], [F(100), F(0x1.a934f0979a3715fcp+2)],
39964007
[F(10000), F(0x1.a934f0979a3715fcp+3)],
39974008
];
39984009
testLog2(vals);
@@ -4178,7 +4189,7 @@ private T logbImpl(T)(T x) @trusted pure nothrow @nogc
41784189
}
41794190
static foreach (F; AliasSeq!(float, double, real))
41804191
{{
4181-
F[2][24] vals = [
4192+
scope F[2][] vals = [
41824193
[F(1), F(0x0p+0)], [F(2), F(0x1p+0)],
41834194
[F(4), F(0x1p+1)], [F(8), F(0x1.8p+1)],
41844195
[F(16), F(0x1p+2)], [F(32), F(0x1.4p+2)],
@@ -4190,6 +4201,9 @@ private T logbImpl(T)(T x) @trusted pure nothrow @nogc
41904201
[F(17), F(0x1p+2)], [F(31), F(0x1p+2)],
41914202
[F(33), F(0x1.4p+2)], [F(63), F(0x1.4p+2)],
41924203
[F(65), F(0x1.8p+2)], [F(-0), -F.infinity], [F(0), -F.infinity],
4204+
[F(0.1), F(-0x1p+2)], [F(0.25), F(-0x1p+1)],
4205+
[F(0.75), F(-0x1p+0)], [F(0.875), F(-0x1p+0)],
4206+
[F(10), F(0x1.8p+1)], [F(100), F(0x1.8p+2)],
41934207
[F(10000), F(0x1.ap+3)],
41944208
];
41954209
testLogb(vals);

0 commit comments

Comments
 (0)