[Issue 12084] New: std.math.poly using Estrin method
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 5 10:16:32 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12084
Summary: std.math.poly using Estrin method
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2014-02-05 10:16:29 PST ---
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.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list