The OpenD Programming Language

findInterval

Interval index for x value given.

template findInterval(size_t dimension = 0)
@trusted
size_t
findInterval
(
Interpolant
X
)
(
auto ref const Interpolant interpolant
,
in X x
)

Members

Functions

findInterval
size_t findInterval(Interpolant interpolant, X x)

Interval index for x value given.

Examples

import mir.ndslice.allocation: rcslice;
import mir.ndslice.topology: as;
import mir.ndslice.slice: sliced;
import mir.interpolate.linear;

static immutable x = [0.0, 1, 2];
static immutable y = [10.0, 2, 4];
auto interpolation = linear!double(x.rcslice, y.as!(const double).rcslice);
assert(interpolation.findInterval(1.0) == 1);

Meta