Bug 12084 – std.math.poly using Estrin method

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-05T10:16:29Z
Last change time
2024-12-01T16:20:05Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#10030 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10030 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB