pub struct CachedOdeProblem<F>{ /* private fields */ }Expand description
A pre-compiled ODE problem for repeated integration (neural ODE pattern).
Once constructed the RK4 graph is fixed: n_steps evaluations of rhs
are performed per integrate call, with no re-allocation of step vectors.
Implementations§
Source§impl<F> CachedOdeProblem<F>
impl<F> CachedOdeProblem<F>
Sourcepub fn new(rhs: F, t0: f64, t1: f64, dt: f64, state_dim: usize) -> Self
pub fn new(rhs: F, t0: f64, t1: f64, dt: f64, state_dim: usize) -> Self
Create a new cached ODE problem.
§Parameters
rhs: Right-hand sidef(t, y, dydt)— writes intodydt.t0,t1: Integration interval[t0, t1].dt: Fixed step size. Actualn_steps = ceil((t1 - t0) / dt).state_dim: Dimensionality of the state vector.
§Errors
Returns IntegrateError::ValueError if dt ≤ 0 or t1 ≤ t0.
Sourcepub fn integrate(&self, y0: &[f64]) -> Result<Vec<f64>, IntegrateError>
pub fn integrate(&self, y0: &[f64]) -> Result<Vec<f64>, IntegrateError>
Integrate from initial state y0 and return the final state.
Pre-allocated scratch buffers are stack-allocated for state_dim ≤ 16
and heap-allocated otherwise; either way no allocation occurs inside
the RK4 loop itself.
Sourcepub fn integrate_batch(
&self,
batch_y0: &[Vec<f64>],
) -> Result<Vec<Vec<f64>>, IntegrateError>
pub fn integrate_batch( &self, batch_y0: &[Vec<f64>], ) -> Result<Vec<Vec<f64>>, IntegrateError>
Batch integration — runs all initial conditions in parallel using Rayon.
Returns one output state vector per input in batch_y0, in the same
order as the inputs.
Auto Trait Implementations§
impl<F> Freeze for CachedOdeProblem<F>
impl<F> RefUnwindSafe for CachedOdeProblem<F>where
F: RefUnwindSafe,
impl<F> Send for CachedOdeProblem<F>
impl<F> Sync for CachedOdeProblem<F>
impl<F> Unpin for CachedOdeProblem<F>
impl<F> UnsafeUnpin for CachedOdeProblem<F>
impl<F> UnwindSafe for CachedOdeProblem<F>where
F: RefUnwindSafe,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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