pub struct BarycentricLagrange<S: Scalar> { /* private fields */ }Expand description
Barycentric Lagrange interpolant.
Evaluates the unique polynomial of degree n-1 passing through n data points
using the numerically stable barycentric formula. O(n) per evaluation after O(n^2) setup.
Implementations§
Source§impl<S: Scalar> BarycentricLagrange<S>
impl<S: Scalar> BarycentricLagrange<S>
Sourcepub fn new(x: &[S], y: &[S]) -> Result<Self, InterpError>
pub fn new(x: &[S], y: &[S]) -> Result<Self, InterpError>
Create a barycentric Lagrange interpolant from data points.
§Errors
Returns error if fewer than 1 point or data is not sorted.
Sourcepub fn chebyshev<F: Fn(S) -> S>(f: F, a: S, b: S, n: usize) -> Self
pub fn chebyshev<F: Fn(S) -> S>(f: F, a: S, b: S, n: usize) -> Self
Create from Chebyshev nodes on [a, b].
Uses n Chebyshev nodes of the first kind, which minimize the
maximum interpolation error (near-optimal for polynomial interpolation).
Uses the known closed-form barycentric weights for numerical stability.
Trait Implementations§
Source§impl<S: Scalar> Interpolant<S> for BarycentricLagrange<S>
impl<S: Scalar> Interpolant<S> for BarycentricLagrange<S>
Source§fn interpolate(&self, x: S) -> S
fn interpolate(&self, x: S) -> S
Evaluate the interpolant at
x.
Extrapolates using the first/last segment if x is outside the data range.Source§fn interpolate_vec(&self, xs: &[S]) -> Vec<S>
fn interpolate_vec(&self, xs: &[S]) -> Vec<S>
Evaluate at multiple points.
Source§fn derivative(&self, x: S) -> Option<S>
fn derivative(&self, x: S) -> Option<S>
First derivative at
x, if available.Auto Trait Implementations§
impl<S> Freeze for BarycentricLagrange<S>
impl<S> RefUnwindSafe for BarycentricLagrange<S>where
S: RefUnwindSafe,
impl<S> Send for BarycentricLagrange<S>
impl<S> Sync for BarycentricLagrange<S>
impl<S> Unpin for BarycentricLagrange<S>where
S: Unpin,
impl<S> UnsafeUnpin for BarycentricLagrange<S>
impl<S> UnwindSafe for BarycentricLagrange<S>where
S: 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