[][src]Struct mathru::analysis::ode::Heun

pub struct Heun<T> { /* fields omitted */ }

Solves an ordinary differential equation using Heun's method.

https://en.wikipedia.org/wiki/Heun's_method

Methods

impl<T> Heun<T>[src]

pub fn new(step_size: T) -> Heun<T>[src]

Creates a Heun instance with step size 'step_size'

Argument

  • 'step_size'

Panics

'step_size' <= 0.0

Trait Implementations

impl<T> Solver<T> for Heun<T> where
    T: Real
[src]

fn solve<F>(
    &self,
    func: F,
    init: Vector<T>,
    t_start: T,
    t_end: T
) -> (Vector<T>, Matrix<T>) where
    F: Fn(&T, &Vector<T>) -> Vector<T>, 
[src]

Solves func using Heun's method.

Arguments

  • 'func' is an explict oridnary diffential equation
  • 'init' is the initial value at the time 't_start'
  • 't_start' initial time
  • 't_end'

Return

The solver returns a vector and a matrix, containing the times used in each step of the algorithm and the respectful values for that time.

Example

use mathru::*;
use mathru::algebra::linear::{Vector, Matrix};
use mathru::analysis::ode::{Solver, Heun};

let f = |t: &f64, _x: &Vector<f64> | -> Vector<f64> { return Vector::new_row(1, vec![1.0]) * (t * &2.0f64); };

let init: Vector<f64> = vector![1.0];
let solver: Heun<f64> = Heun::new(0.01);

let (t, y): (Vector<f64>, Matrix<f64>) = solver.solve(f, init, 0.0, 2.0);

Auto Trait Implementations

impl<T> Send for Heun<T> where
    T: Send

impl<T> Sync for Heun<T> where
    T: Sync

impl<T> Unpin for Heun<T> where
    T: Unpin

impl<T> UnwindSafe for Heun<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for Heun<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,