interpolate::curve
The interface of every 1-d interpolant, and what it does outside its data.
Enums
ExtrapolateSource
pub enum ExtrapolateWhat an interpolant gives outside [x[0], x[n - 1]].
nabi
use interpolate::{Curve, Extrapolate};
let f = try interpolate::linear([0, 1], [0, 2]);
assert(f.at(2.0) == 4.0); // Extend
assert(f.extrapolate(Extrapolate::Clamp).at(2.0) == 2.0);
assert(f.extrapolate(Extrapolate::Fill(-1.0)).at(2.0) == -1.0);
assert(f.extrapolate(Extrapolate::Periodic).at(1.5) == 1.0);
Continue the first and last pieces (the default).
Hold the end values.
This value, NaN for "no answer".
Wrap
xinto the data range with periodx[n - 1] - x[0].
Traits
CurveSource
pub trait CurveA function of one variable built from data. Every interpolant is
called like a function: s(x) at one point, s(xs) at every element
of an array of any rank (xs |> s and s.(xs) too). at and eval
are the two calls by name, and func gives a plain fn(f64) -> f64
for an API that wants one.
nabi
use interpolate::Curve;
use core::array::Vector;
let s = try interpolate::cubic_spline([0, 1, 2, 3], [0, 1, 8, 27]);
let xs: Vector<f64> = [0.5, 1.5];
let ys = s(xs);
assert(ys[1] == s(1.5) && s.at(1.5) == ys[1]);
assert(s([0.5, 1.5]) == ys && s(2) == 8.0);
assert((xs |> s) == ys && s.(xs) == ys);
let f = s.func();
assert(f(1.5) == ys[1]);
The value at
x.The value at every element of
xs, in an array of its shape.atas a function value, for an API that takesfn(f64) -> f64(quad,List::map).