Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
mir.interpolate.constant
Constant Interpolation
See Also:
License:
Authors:
Ilia Ki
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);
- public import mir.interpolate :
atInterval; - Constant!(F, N, X)
constant(F, size_t N = 1, X = F)(Repeat!(N, Slice!(RCI!(immutable(X))))grid, Slice!(RCI!(const(F)), N)values); - Constructs multivariate constant interpolant with nodes on rectilinear grid.Parameters:
Repeat!(N, Slice!(RCI!(immutable(X)))) gridx values for interpolant Slice!(RCI!(const(F)), N) valuesf(x) values for interpolant Constraints
grid,valuesmust have the same length >= 1Returns: - struct
Constant(F, size_t N = 1, X = F) if (N && (N <= 6)); - Multivariate constant interpolant with nodes on rectilinear grid.
- Slice!(RCI!(const(F)), N)
_data; - Aligned buffer allocated with mir.internal.memory. For internal use.
- Repeat!(N, RCI!(immutable(X)))
_grid; - Grid iterators. For internal use.
- @nogc @safe this(Repeat!(N, Slice!(RCI!(immutable(X))))
grid, Slice!(RCI!(const(F)), N)data); - const @property Constant
lightConst()(); - const @property Slice!(RCI!(immutable(X)))
grid(size_t dimension = 0)() return scope
if (dimension < N); - const @property @trusted immutable(X)[]
gridScopeView(size_t dimension = 0)() return scope
if (dimension < N); - const @property size_t
intervalCount(size_t dimension = 0)() scope; - Returns:intervals count.
- const @property size_t[N]
gridShape()() scope; - enum uint
derivativeOrder; - enum uint
dimensionCount; - template
opCall(uint derivative = 0) -
- const @trusted auto
opCall(X...)(in Xxs) scope
if (X.length == N); - (x) operator.
Complexity O(log(grid.length))
- SingleConstant!F
singleConstant(F)(const Fvalue);
structSingleConstant(F, X = F); - Single value interpolationExamples:
auto sc = singleConstant(34.1); assert(sc(100) == 34.1); assert(sc.opCall!2(100) == [34.1, 0, 0]);
- auto
metaSingleConstant(T)(Tdata);
structMetaSingleConstant(T, X = double); - Interpolator used for non-rectiliner trapezoid-like greeds.Parameters:
grid rc-array of interpolation grid T datarc-array of interpolator-like structures Examples:Ignores the first dimension parameterimport 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 d = linear!double(x.rcslice!(immutable double), y.rcslice!(const double)); auto ignoresFirstDim = d.metaSingleConstant; assert(ignoresFirstDim(9.0, 1.8) == d(1.8)); assert(ignoresFirstDim.opCall!1(9.0, 1.8) == [d.opCall!1(1.8), [0.0, 0.0]]);
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:03 2026