pub struct HermiteInterp<T, const N: usize> { /* private fields */ }Expand description
Cubic Hermite interpolant (fixed-size, stack-allocated).
Uses user-supplied derivatives at each knot. Each segment is a cubic polynomial matching both value and first derivative at its endpoints. Requires at least 2 points.
§Example
use numeris::interp::HermiteInterp;
// Interpolate sin(x) with known derivatives cos(x)
let xs = [0.0_f64, 1.0, 2.0];
let ys = [0.0_f64.sin(), 1.0_f64.sin(), 2.0_f64.sin()];
let dys = [0.0_f64.cos(), 1.0_f64.cos(), 2.0_f64.cos()];
let interp = HermiteInterp::new(xs, ys, dys).unwrap();
let mid = 0.5;
assert!((interp.eval(mid) - mid.sin()).abs() < 0.002);Implementations§
Source§impl<T: FloatScalar, const N: usize> HermiteInterp<T, N>
impl<T: FloatScalar, const N: usize> HermiteInterp<T, N>
Sourcepub fn new(xs: [T; N], ys: [T; N], dys: [T; N]) -> Result<Self, InterpError>
pub fn new(xs: [T; N], ys: [T; N], dys: [T; N]) -> Result<Self, InterpError>
Construct a Hermite interpolant from knots and derivatives.
Sourcepub fn eval_derivative(&self, x: T) -> (T, T)
pub fn eval_derivative(&self, x: T) -> (T, T)
Evaluate the interpolant and its derivative at x.
Trait Implementations§
Source§impl<T: Clone, const N: usize> Clone for HermiteInterp<T, N>
impl<T: Clone, const N: usize> Clone for HermiteInterp<T, N>
Source§fn clone(&self) -> HermiteInterp<T, N>
fn clone(&self) -> HermiteInterp<T, N>
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 moreAuto Trait Implementations§
impl<T, const N: usize> Freeze for HermiteInterp<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for HermiteInterp<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for HermiteInterp<T, N>where
T: Send,
impl<T, const N: usize> Sync for HermiteInterp<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for HermiteInterp<T, N>where
T: Unpin,
impl<T, const N: usize> UnsafeUnpin for HermiteInterp<T, N>where
T: UnsafeUnpin,
impl<T, const N: usize> UnwindSafe for HermiteInterp<T, N>where
T: UnwindSafe,
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.