Skip to main content

HermiteInterp

Struct HermiteInterp 

Source
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>

Source

pub fn new(xs: [T; N], ys: [T; N], dys: [T; N]) -> Result<Self, InterpError>

Construct a Hermite interpolant from knots and derivatives.

Source

pub fn eval(&self, x: T) -> T

Evaluate the interpolant at x.

Source

pub fn eval_derivative(&self, x: T) -> (T, T)

Evaluate the interpolant and its derivative at x.

Source

pub fn xs(&self) -> &[T; N]

The knot x-values.

Source

pub fn ys(&self) -> &[T; N]

The knot y-values.

Trait Implementations§

Source§

impl<T: Clone, const N: usize> Clone for HermiteInterp<T, N>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, const N: usize> Debug for HermiteInterp<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.