The OpenD Programming Language

mir.interpolate.constant

Members

Functions

atInterval (from mir.interpolate)
Tuple!(T, size_t) atInterval(T value, size_t intervalIndex) via public import mir.interpolate : atInterval;
constant
Constant!(F, N, X) constant(Repeat!(N, Slice!(RCI!(immutable X))) grid, Slice!(RCI!(const F), N) values)

Constructs multivariate constant interpolant with nodes on rectilinear grid.

metaSingleConstant
auto metaSingleConstant(T data)

Interpolator used for non-rectiliner trapezoid-like greeds.

singleConstant
SingleConstant!F singleConstant(F value)

Single value interpolation

Structs

Constant
struct Constant(F, size_t N = 1, X = F)

Multivariate constant interpolant with nodes on rectilinear grid.

MetaSingleConstant
struct MetaSingleConstant(T, X = double)

Interpolator used for non-rectiliner trapezoid-like greeds.

SingleConstant
struct SingleConstant(F, X = F)

Single value interpolation

Examples

import mir.ndslice;
import mir.math.common: approxEqual;

static immutable x = [0, 1, 2, 3];
static immutable y = [10, 20, 30, 40];

auto interpolant = constant!int(x.rcslice, y.rcslice!(const int));

assert(interpolant(-1) == 10);
assert(interpolant(0) == 10);
assert(interpolant(0.5) == 10);

assert(interpolant(1) == 20);

assert(interpolant(3) == 40);
assert(interpolant(4) == 40);

See Also

Meta

Authors

Ilia Ki