Comment #0 by bearophile_hugs — 2014-02-05T10:16:29Z
Part of the docs of std.math.poly:
pure nothrow @trusted real poly(real x, const real[] A);
Evaluate polynomial A(x) = a0 + a1x + a2x2 + a3x3; ...
Uses Horner's rule A(x) = a0 + x(a1 + x(a2 + x(a3 + ...)))
Its fallback code when asm is not available:
{
ptrdiff_t i = A.length - 1;
real r = A[i];
while (--i >= 0)
{
r *= x;
r += A[i];
}
return r;
}
But on modern CPUs this algorithm is usually more efficient:
http://en.wikipedia.org/wiki/Estrin%27s_scheme
See also for an example:
http://lolengine.net/blog/2011/9/17/playing-with-the-cpu-pipeline
I also suspect that with gdc and ldc2 the asm code is not necessary.
Comment #1 by robert.schadek — 2024-12-01T16:20:05Z