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.mod
Interpolation Modifier
License:
Authors:
Ilia Ki
- template
interpolationMap(alias fun)
templateInterpolationMap(alias fun) - Applies function to the interpolated value.Parameters:
fun two arguments (x, derivativeOrder) function Examples:import mir.interpolate.spline; import mir.math.common: log; import mir.ndslice.allocation: rcslice; import mir.test; alias g = (double x, uint d = 0) => d == 0 ? 3 * x ^^ 3 + 5 * x ^^ 2 + 0.23 * x + 2 : d == 1 ? 9 * x ^^ 2 + 10 * x + 0.23 : double.nan; alias f = (double x, ref scope y) { y[0] = log(x); static if (y.length >= 2) y[1] = 1 / x; static if (y.length >= 3) y[2] = -y[1] * y[1]; static if (y.length >= 4) y[3] = -2 * y[1] * y[2]; static if (y.length >= 5) static assert(0, "Not implemented"); }; auto s = spline!double( [0.1, 0.4, 0.5, 1.0].rcslice!(immutable double), [g(0.1), g(0.4), g(0.5), g(1.0)].rcslice!(const double) ); auto m = s.interpolationMap!f; m(0.7).shouldApprox == log(g(0.7)); auto d = m.opCall!3(0.7); d[0].shouldApprox == log(g(0.7)); d[1].shouldApprox == 1 / g(0.7) * g(0.7, 1); d[2].shouldApprox == -0.252301; d[3].shouldApprox == -4.03705;
- auto
interpolationMap(T)(Tinterpolator);
- alias
interpolationSqrt= interpolationMap!(__lambda_L161_C9).interpolationMap(T)(T interpolator);
aliasInterpolationSqrt= InterpolationMap!(__lambda_L161_C9).InterpolationMap(T); - Applies square root function to the interpolated value.Examples:
import mir.interpolate.spline; import mir.math.common: sqrt; import mir.ndslice.allocation: rcslice; import mir.test; alias g = (double x, uint d = 0) => d == 0 ? 3 * x ^^ 3 + 5 * x ^^ 2 + 0.23 * x + 2 : d == 1 ? 9 * x ^^ 2 + 10 * x + 0.23 : double.nan; auto s = spline!double( [0.1, 0.4, 0.5, 1.0].rcslice!(immutable double), [g(0.1), g(0.4), g(0.5), g(1.0)].rcslice!(const double) ); auto m = s.interpolationSqrt; m(0.7).shouldApprox == sqrt(g(0.7)); auto d = m.opCall!3(0.7); d[0].shouldApprox == sqrt(g(0.7)); d[1].shouldApprox == 0.5 / sqrt(g(0.7)) * g(0.7, 1); d[2].shouldApprox == 2.2292836438189414; d[3].shouldApprox == -3.11161;
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:04 2026