The OpenD Programming Language

polynomial

Polynomial callable ref-counted structure.

polynomial
(
F
)
()

Examples

import mir.test;
import mir.rc.array;
auto a = rcarray!(const double)(3.0, 4.5, 1.9, 2);
auto p = a.polynomial;

alias f = (x) => 3.0 + 4.5 * x^^1 + 1.9 * x^^2 + 2 * x^^3;
alias df = (x) => 4.5 + 2 * 1.9 * x^^1 + 3 * 2 * x^^2;
alias d2f = (x) => 2 * 1.9  + 6 * 2 * x^^1;

p(3.3).shouldApprox == f(3.3);
p(7.2).shouldApprox == f(7.2);

p.opCall!1(3.3).shouldApprox == df(3.3);
p.opCall!1(7.2).shouldApprox == df(7.2);

p.opCall!2(3.3).shouldApprox == d2f(3.3);
p.opCall!2(7.2).shouldApprox == d2f(7.2);

Meta