pub struct Tabulated<S: Scalar> {
pub times: Vec<S>,
pub values: Vec<S>,
pub interp: Interpolation,
/* private fields */
}Expand description
Signal from tabulated time-value data.
Interpolates between given data points using linear, nearest-neighbor, or cubic spline interpolation.
§Example
use numra_core::signal::{Signal, Tabulated, Interpolation};
let times: Vec<f64> = vec![0.0, 1.0, 2.0, 3.0];
let values: Vec<f64> = vec![0.0, 1.0, 0.0, 2.0];
let signal = Tabulated::new(times, values, Interpolation::Linear);
assert!((signal.value_at(0.5) - 0.5).abs() < 1e-10); // Midpoint interpolation
assert!((signal.value_at(1.0) - 1.0).abs() < 1e-10); // Exact point§Cubic Spline Interpolation
When using Interpolation::Cubic, natural cubic splines provide
smooth C² continuous interpolation between data points.
Fields§
§times: Vec<S>§values: Vec<S>§interp: InterpolationImplementations§
Source§impl<S: Scalar> Tabulated<S>
impl<S: Scalar> Tabulated<S>
Sourcepub fn new(times: Vec<S>, values: Vec<S>, interp: Interpolation) -> Self
pub fn new(times: Vec<S>, values: Vec<S>, interp: Interpolation) -> Self
Create a new tabulated signal.
§Panics
Panics if times and values have different lengths, or if times is empty.
Sourcepub fn from_pairs(pairs: &[(S, S)], interp: Interpolation) -> Self
pub fn from_pairs(pairs: &[(S, S)], interp: Interpolation) -> Self
Create from slice pairs.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Tabulated<S>
impl<S> RefUnwindSafe for Tabulated<S>where
S: RefUnwindSafe,
impl<S> Send for Tabulated<S>
impl<S> Sync for Tabulated<S>
impl<S> Unpin for Tabulated<S>where
S: Unpin,
impl<S> UnsafeUnpin for Tabulated<S>
impl<S> UnwindSafe for Tabulated<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