The OpenD Programming Language

metaLinear

Interpolator used for non-rectiliner trapezoid-like greeds.

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

Parameters

grid RCArray!(immutable X)

rc-array of interpolation grid

data RCArray!(const T)

rc-array of interpolator-like structures

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