The OpenD Programming Language

MetaLinear

Interpolator used for non-rectiliner trapezoid-like greeds.

Constructors

this
this(RCArray!(immutable X) grid, RCArray!(const T) data)

Members

Aliases

withDerivative
alias withDerivative = opCall!1
withTwoDerivatives
alias withTwoDerivatives = opCall!2

Functions

gridScopeView
immutable(X)[] gridScopeView()
intervalCount
size_t intervalCount()
lightConst
MetaLinear lightConst()

Templates

opCall
template opCall(uint derivative = 0)

Variables

data
RCArray!(const T) data;
derivativeOrder
enum uint derivativeOrder;
dimensionCount
enum uint dimensionCount;
grid
RCArray!(immutable X) grid;

Examples

2D trapezoid-like (not rectilinear) linear interpolation

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

auto g = [7.0, 10, 15];

import mir.rc.array: RCArray;
import mir.ndslice.allocation: rcslice;

auto d = RCArray!(Linear!double)(3);

foreach (i; 0 .. x.length)
    d[i] = linear!double(x[i].rcslice!(immutable double), y[i].rcslice!(const double));

auto trapezoidInterpolator = metaLinear(g.rcarray!(immutable double), d.lightConst);

auto val = trapezoidInterpolator(9.0, 1.8);
auto valWithDerivative = trapezoidInterpolator.withDerivative(9.0, 1.8);

Meta