pub struct Table1D { /* private fields */ }Expand description
A one-dimensional lookup table y(x).
Built through Table1D::new, which checks the knots; it serializes as its knots and
policies (x, y, interpolation, extrapolation) and re-checks them when deserialized.
Implementations§
Source§impl Table1D
impl Table1D
Sourcepub fn new(
xs: Vec<f64>,
ys: Vec<f64>,
interpolation: Interpolation,
extrapolation: Extrapolation,
) -> Result<Self, CoreError>
pub fn new( xs: Vec<f64>, ys: Vec<f64>, interpolation: Interpolation, extrapolation: Extrapolation, ) -> Result<Self, CoreError>
Builds a table from its abscissae xs and ordinates ys.
§Errors
CoreError::TableLengthMismatchif the columns differ in length.CoreError::TableTooShortwith fewer thanTable1D::MIN_KNOTSknots.CoreError::TableNotFiniteif any value is NaN or infinite.CoreError::TableNotIncreasingunlessxsstrictly increases.CoreError::TableOverflowif an interval’s widthx_{i+1} − x_i, its secant slope, or a spline slope is not representable as a finitef64.
Sourcepub fn interpolation(&self) -> Interpolation
pub fn interpolation(&self) -> Interpolation
The interpolation between knots.
Sourcepub fn extrapolation(&self) -> Extrapolation
pub fn extrapolation(&self) -> Extrapolation
The extrapolation policy.
Sourcepub fn lookup(&self, x: f64) -> Result<Lookup, CoreError>
pub fn lookup(&self, x: f64) -> Result<Lookup, CoreError>
Looks up y(x), reporting whether the value was extrapolated.
§Errors
CoreError::NanLookupifxis NaN.CoreError::OutOfRangeifxis outside the table and the policy isExtrapolation::Error.CoreError::ExtrapolationOverflowif linear extrapolation does not give a finite value (xinfinite, or so far out that the line overflows).
Sourcepub fn eval(&self, x: f64) -> Result<f64, CoreError>
pub fn eval(&self, x: f64) -> Result<f64, CoreError>
Looks up y(x); the same as Table1D::lookup without the extrapolation flag.
§Errors
As Table1D::lookup.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Table1D
impl<'de> Deserialize<'de> for Table1D
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Table1D
Auto Trait Implementations§
impl Freeze for Table1D
impl RefUnwindSafe for Table1D
impl Send for Table1D
impl Sync for Table1D
impl Unpin for Table1D
impl UnsafeUnpin for Table1D
impl UnwindSafe for Table1D
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