The OpenD Programming Language

constantExtrapolator

Constant extrapolator

  1. ConstantExtrapolator!T constantExtrapolator(T interpolator)
    constantExtrapolator
    (
    T
    )
  2. struct ConstantExtrapolator(T)

Examples

import mir.interpolate.linear;

auto x = [0.0, 1, 2, 3, 5];
auto y = [4.0, 0, 9, 23, 40];

auto g = [7.0, 10, 15];

import mir.ndslice.allocation: rcslice;

auto linear = linear!double(
    x.rcslice!(immutable double),
    y.rcslice!(const double),
).constantExtrapolator;

assert(linear(2) == 9);
assert(linear(-1) == 4);
assert(linear(100) == 40);

assert(linear.opCall!1(-1) == [4, 0]);

Meta