The OpenD Programming Language

Interp1

Lazy interpolation shell with linear complexity.

Members

Functions

empty
bool empty()
front
auto front()

Input range primitives

length
size_t length()

Length (optional)

lightScope
auto lightScope()
popFront
void popFront()

Input range primitives

save
auto save()

Save primitive (optional)

Return Value

Lazy input range.

Examples

PCHIP interpolation.

import mir.math.common: approxEqual;
import mir.ndslice.slice: sliced;
import mir.ndslice.allocation: rcslice;
import mir.interpolate: interp1;
import mir.interpolate.spline;

static immutable x = [1.0, 2, 4, 5, 8, 10, 12, 15, 19, 22];
static immutable y = [17.0, 0, 16, 4, 10, 15, 19, 5, 18, 6];
auto interpolation = spline!double(x.rcslice, y.sliced, SplineType.monotone);

auto xs = x[0 .. $ - 1].sliced + 0.5;

auto ys = xs.interp1(interpolation);

See Also

Meta