Why is std.math slower than the C baseline?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jun 5 19:48:55 UTC 2020
On Fri, Jun 05, 2020 at 03:39:26PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> On 6/4/20 10:39 AM, jmh530 wrote:
[...]
> > Below is a typical example of a std.math implementation for a trig
> > function. It casts everything to real to improve accuracy. This
> > doesn't explain everything, but it's a general strategy in std.math
> > to prefer accuracy over speed.
> >
> > real cosh(real x) @safe pure nothrow @nogc
> > {
[...]
> > }
> >
> > /// ditto
> > double cosh(double x) @safe pure nothrow @nogc { return cosh(cast(real)
> > x); }
> >
> > /// ditto
> > float cosh(float x) @safe pure nothrow @nogc { return cosh(cast(real)
> > x); }
>
> This needs to change. It's one thing to offer more precision to the
> user who consciously uses 80-bit reals, and it's an entirely different
> thing to force that bias on the user who's okay with double precision.
+100! std.math has been pessimal for all these years for no good
reason, let's get this fixed by making sure this gets pushed through:
https://github.com/dlang/phobos/pull/7463
AIUI, it's currently only held up by a single 3rd party package awaiting
a new release. Once that's done, we need to rectify this pessimal state
of affairs.
T
--
All men are mortal. Socrates is mortal. Therefore all men are Socrates.
More information about the Digitalmars-d
mailing list