mir.interpolate.constant

Constant Interpolation

Public Imports

mir.interpolate
public import mir.interpolate : atInterval;

Members

Functions

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.

Structs

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

Multivariate constant interpolant with nodes on rectilinear grid.

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

License

Apache-2.0

Authors

Ilya Yaroshenko