pub fn solve_ivp<F>(fun: F, t_span: (f32, f32), y0: DVector<f32>, method: IntegratorType, options: SolverOptions)
    -> Result< (Vec<f32>, Vec<DVector<f32>>), IntegrateError >
where
    F: Fn(f32, &DVector<f32>) -> DVector<f32>,
{

    if t_span.0 < 0.0 || t_span.0 >= t_span.1 || t_span.1 <= 0.0 {
        return Err(IntegrateError::ArgError("t_span".to_string()));
    }

    let (t0, tf) = t_span;
    let step = match options.first_step {
        Some(value) => value,
        None => (tf - t0)/1000.0
    };
    let rtol = options.rtol;
    let _atol = options.atol;

    // TODO: propogate errors from the individual functions
    let (t_steps, trajectory) = match method {

        IntegratorType::ForwardEuler => ForwardEuler(fun, t0, y0, tf, step),
        IntegratorType::MidpointEuler => MidPointEuler(fun, t0, y0, tf, step),
        IntegratorType::RKF45 => RKF45(fun, t0, y0, tf, step, rtol),
        IntegratorType::RK45 => RK45(fun, t0, y0, tf, step, rtol)

    };

    Ok( (t_steps, trajectory) )

}
/// Integrates a system of ordinary differential equations given an initial value
Integrates a system of ordinary differential equations given an initial value
Integrates a system of ordinary differential equations given an initial value
pub fn solve_ivp<F>(fun: F, t_span: (f32, f32), y0: DVector<f32>, method: IntegratorType, options: SolverOptions)
    -> Result< (Vec<f32>, Vec<DVector<f32>>), IntegrateError >
where
    F: Fn(f32, &DVector<f32>) -> DVector<f32>,
{
    if t_span.0 < 0.0 || t_span.0 >= t_span.1 || t_span.1 <= 0.0 {
        return Err(IntegrateError::ArgError("t_span".to_string()));
    }
    let (t0, tf) = t_span;
    let step = match options.first_step {
        Some(value) => value,
        None => (tf - t0)/1000.0
    };
    let rtol = options.rtol;
    let _atol = options.atol;
    // TODO: propogate errors from the individual functions
    let (t_steps, trajectory) = match method {
        IntegratorType::ForwardEuler => ForwardEuler(fun, t0, y0, tf, step),
        IntegratorType::MidpointEuler => MidPointEuler(fun, t0, y0, tf, step),
        IntegratorType::RKF45 => RKF45(fun, t0, y0, tf, step, rtol),
        IntegratorType::RK45 => RK45(fun, t0, y0, tf, step, rtol)
    };
    Ok( (t_steps, trajectory) )
}
pub fn solve_ivp < F > ( fun : F , t_span : ( f32 , f32 ) , y0 : DVector < f32 > , method : IntegratorType , options : SolverOptions ) -> Result < ( Vec < f32 > , Vec < DVector < f32 > > ) , IntegrateError > where F : Fn ( f32 , & DVector < f32 > ) -> DVector < f32 > , { if t_span . 0 < 0.0 || t_span . 0 >= t_span . 1 || t_span . 1 <= 0.0 { return Err ( IntegrateError :: ArgError ( " " . to_string ( ) ) ) ; } let ( t0 , tf ) = t_span ; let step = match options . first_step { Some ( value ) => value , None => ( tf - t0 ) / 1000.0 } ; let rtol = options . rtol ; let _atol = options . atol ; // TODO: propogate errors from the individual functions let ( t_steps , trajectory ) = match method { IntegratorType :: ForwardEuler => ForwardEuler ( fun , t0 , y0 , tf , step ) , IntegratorType :: MidpointEuler => MidPointEuler ( fun , t0 , y0 , tf , step ) , IntegratorType :: RKF45 => RKF45 ( fun , t0 , y0 , tf , step , rtol ) , IntegratorType :: RK45 => RK45 ( fun , t0 , y0 , tf , step , rtol ) } ; Ok ( ( t_steps , trajectory ) ) }
Integrates a system of ordinary differential equations given an initial value
Integrates a system of ordinary differential equations given an initial value
fun
F
t_span
(f32, f32)
y0
DVector<f32>
method
IntegratorType
options
SolverOptions
fun
F
t_span
(f32, f32)
y0
DVector<f32>
method
IntegratorType
options
SolverOptions