mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 06:00:35 +03:00
commit
9d4f5ef889
1 changed files with 23 additions and 21 deletions
44
std/math.d
44
std/math.d
|
@ -6240,14 +6240,7 @@ body
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptrdiff_t i = A.length - 1;
|
return polyImplBase(x, A);
|
||||||
typeof(return) r = A[i];
|
|
||||||
while (--i >= 0)
|
|
||||||
{
|
|
||||||
r *= x;
|
|
||||||
r += A[i];
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6272,15 +6265,31 @@ body
|
||||||
assert(poly(x, pp) == y);
|
assert(poly(x, pp) == y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc
|
unittest {
|
||||||
in
|
static assert(poly(3.0, [1.0, 2.0, 3.0]) == 34);
|
||||||
{
|
|
||||||
assert(A.length > 0);
|
|
||||||
}
|
}
|
||||||
body
|
|
||||||
|
private Unqual!(CommonType!(T1, T2)) polyImplBase(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc
|
||||||
|
if (isFloatingPoint!T1 && isFloatingPoint!T2)
|
||||||
|
{
|
||||||
|
ptrdiff_t i = A.length - 1;
|
||||||
|
typeof(return) r = A[i];
|
||||||
|
while (--i >= 0)
|
||||||
|
{
|
||||||
|
r *= x;
|
||||||
|
r += A[i];
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc
|
||||||
{
|
{
|
||||||
version (D_InlineAsm_X86)
|
version (D_InlineAsm_X86)
|
||||||
{
|
{
|
||||||
|
if(__ctfe)
|
||||||
|
{
|
||||||
|
return polyImplBase(x, A);
|
||||||
|
}
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
// BUG: This code assumes a frame pointer in EBP.
|
// BUG: This code assumes a frame pointer in EBP.
|
||||||
|
@ -6429,14 +6438,7 @@ body
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptrdiff_t i = A.length - 1;
|
return polyImplBase(x, A);
|
||||||
real r = A[i];
|
|
||||||
while (--i >= 0)
|
|
||||||
{
|
|
||||||
r *= x;
|
|
||||||
r += A[i];
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue