The OpenD Programming Language

CubicKernel

Cubic function structure

Constructors

this
this(T a, T b, T c, T d)

Members

Aliases

withDerivative
alias withDerivative = opCall!1
withTwoDerivatives
alias withTwoDerivatives = opCall!2

Functions

opCall
auto opCall(T x)

Static functions

fromSecondAndFirstDerivative
CubicKernel fromSecondAndFirstDerivative(T x0, T x1, T y0, T y1, T dd0, T d1)

Variables

a
T a;
b
T b;
c
T c;
d
T d;

Examples

import mir.math.common: approxEqual;

alias f = (double x) => 3 * x ^^ 3 + 7 * x ^^ 2 + 5 * x + 10;
alias d = (double x) => 3 * 3 * x ^^ 2 + 2 * 7 * x + 5;
alias s = (double x) => 6 * 3 * x + 2 * 7;
auto x0 = 4;
auto x1 = 9;
auto p = CubicKernel!double.fromSecondAndFirstDerivative(x0, x1, f(x0), f(x1), s(x0), d(x1));

assert(p.a.approxEqual(3));
assert(p.b.approxEqual(7));
assert(p.c.approxEqual(5));
assert(p.d.approxEqual(10));
assert(p(13).approxEqual(f(13)));
assert(p.opCall!1(13)[1].approxEqual(d(13)));
assert(p.opCall!2(13)[2].approxEqual(s(13)));
assert(p.opCall!3(13)[3].approxEqual(18));

Meta