The OpenD Programming Language

interp1

Lazy interpolation shell with linear complexity.

interp1
(
Range
Interpolant
)
(
Range range
,
Interpolant interpolant
,
size_t interval = 0
)

Parameters

range Range

sorted range

interpolant Interpolant

interpolant structure with .gridScopeView method. Complexity: O(range.length + interpolant.gridScopeView.length) to evaluate all elements.

Return Value

Type: auto

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