poly

Evaluate polynomial A(x) = a0 + a1x + a2x2 + a3x3; ...

Uses Horner's rule A(x) = a0 + x(a1 + x(a2 + x(a3 + ...)))

  1. Unqual!(CommonType!(T1, T2)) poly(T1 x, T2[] A)
  2. Unqual!(CommonType!(T1, T2)) poly(T1 x, T2[N] A)
    @safe pure nothrow @nogc
    Unqual!(CommonType!(T1, T2))
    poly
    (
    T1
    T2
    int N
    )
    (
    T1 x
    ,
    ref const T2[N] A
    )
    if (
    N > 0
    &&
    N <= 10
    )

Parameters

x T1

the value to evaluate.

A T2[N]

array of coefficients a0, a1, etc.

Examples

real x = 3.1L;
static real[] pp = [56.1L, 32.7L, 6];

assert(poly(x, pp) == (56.1L + (32.7L + 6.0L * x) * x));

Meta