Struct Covariate
pub struct Covariate { /* private fields */ }
Expand description
A time-varying covariate consisting of computed segments
The covariate holds interpolated segments that are rebuilt whenever observations are modified. Original observation data is stored within the segments themselves.
Implementations§
§impl Covariate
impl Covariate
pub fn new(name: String, fixed: bool) -> Covariate
pub fn new(name: String, fixed: bool) -> Covariate
Create a new covariate with the given name
§Arguments
name
- The name of the covariatefixed
- Whether this covariate should use carry-forward interpolation
pub fn add_observation(&mut self, time: f64, value: f64)
pub fn add_observation(&mut self, time: f64, value: f64)
Add an observation to this covariate
If an observation already exists at this time, it will update that value instead of adding a new one.
pub fn update_observation(&mut self, time: f64, new_value: f64)
pub fn update_observation(&mut self, time: f64, new_value: f64)
Update an observation at a specific time
pub fn remove_observation(&mut self, time: f64) -> bool
pub fn remove_observation(&mut self, time: f64) -> bool
Remove an observation at a specific time
pub fn observations(&self) -> Vec<(f64, f64)>
pub fn observations(&self) -> Vec<(f64, f64)>
Get all raw observations as time-value pairs
pub fn interpolate(&self, time: f64) -> Result<f64, CovariateError>
pub fn interpolate(&self, time: f64) -> Result<f64, CovariateError>
Interpolate the covariate value at a specific time
Returns the interpolated value if the time falls within any segment’s range, otherwise returns the last known observation value.
This method is optimized for sequential access patterns common in ODE solvers by caching the last used segment index.
Trait Implementations§
§impl<'de> Deserialize<'de> for Covariate
impl<'de> Deserialize<'de> for Covariate
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Covariate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Covariate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Covariate
impl Serialize for Covariate
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Covariate
impl RefUnwindSafe for Covariate
impl Send for Covariate
impl Sync for Covariate
impl Unpin for Covariate
impl UnwindSafe for Covariate
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.