pub struct LinearInterpolator { /* private fields */ }Expand description
Linear interpolation between data points.
The simplest form of interpolation, connecting consecutive points with straight lines.
§Example
use convex_math::interpolation::{LinearInterpolator, Interpolator};
let xs = vec![0.0, 1.0, 2.0, 3.0];
let ys = vec![0.0, 1.0, 4.0, 9.0];
let interp = LinearInterpolator::new(xs, ys).unwrap();
let y = interp.interpolate(1.5).unwrap();
// y = 2.5 (linear interpolation between (1, 1) and (2, 4))Implementations§
Source§impl LinearInterpolator
impl LinearInterpolator
Sourcepub fn with_extrapolation(self) -> Self
pub fn with_extrapolation(self) -> Self
Enables extrapolation beyond the data range.
Trait Implementations§
Source§impl Clone for LinearInterpolator
impl Clone for LinearInterpolator
Source§fn clone(&self) -> LinearInterpolator
fn clone(&self) -> LinearInterpolator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearInterpolator
impl Debug for LinearInterpolator
Source§impl Interpolator for LinearInterpolator
impl Interpolator for LinearInterpolator
Source§fn interpolate(&self, x: f64) -> MathResult<f64>
fn interpolate(&self, x: f64) -> MathResult<f64>
Returns the interpolated value at x.
Source§fn derivative(&self, x: f64) -> MathResult<f64>
fn derivative(&self, x: f64) -> MathResult<f64>
Returns the first derivative at x. Read more
Source§fn allows_extrapolation(&self) -> bool
fn allows_extrapolation(&self) -> bool
Returns true if extrapolation is allowed.
Auto Trait Implementations§
impl Freeze for LinearInterpolator
impl RefUnwindSafe for LinearInterpolator
impl Send for LinearInterpolator
impl Sync for LinearInterpolator
impl Unpin for LinearInterpolator
impl UnwindSafe for LinearInterpolator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.