numint

Trait OdeState

Source
pub trait OdeState: Clone {
    // Required methods
    fn add(&self, other: &Self) -> Self;
    fn add_assign(&mut self, other: &Self);
    fn sub(&self, other: &Self) -> Self;
    fn sub_assign(&mut self, other: &Self);
    fn mul(&self, scalar: f64) -> Self;
    fn mul_assign(&mut self, scalar: f64);
    fn get_state_variable(&self, index: StateIndex) -> f64;
}
Expand description

Trait defining an ODE solver state (i.e. the dependent variable in an ODE).

Any type implementing this trait can be used as the dependent variable in an ODE.

This crate implements this trait for the following types:

  • f64
  • Vec<f64>
  • linalg_traits::Mat<f64>
  • nalgebra::DVector<f64>
  • nalgebra::SVector<f64, N>
  • nalgebra::DMatrix<f64>
  • nalgebra::SMatrix<f64, R, C>
  • ndarray::Array1<f64>
  • ndarray::Array2<f64>

§Note on the lack of blanket implementations

We cannot perform blanket implementations using linalg_traits::Scalar, linalg_traits::Vector, and linalg_traits::Matrix. There is nothing restricting types from implementing a combination of these three traits, so the compiler will not allow blanket implementations binding to these traits to avoid any potential conflicting implementations.

Required Methods§

Source

fn add(&self, other: &Self) -> Self

Addition (self + other).

§Arguments
  • other - The other state to add to this state.
§Returns

Sum of this state with the other state (i.e. self + other).

§Panics
  • If self and other are dynamically-sized types and do not have the same length (for vectors) or shape (for matrices).
Source

fn add_assign(&mut self, other: &Self)

In-place addition (self += other).

§Arguments
  • other - The other state to add to this state.
§Panics
  • If self and other are dynamically-sized types and do not have the same length (for vectors) or shape (for matrices).
Source

fn sub(&self, other: &Self) -> Self

Subtraction (self + other).

§Arguments
  • other - The other state to subtract from this state.
§Returns

Difference of this state with the other state (i.e. self - other).

§Panics
  • If self and other are dynamically-sized types and do not have the same length (for vectors) or shape (for matrices).
Source

fn sub_assign(&mut self, other: &Self)

In-place subtraction (self -= other).

§Arguments
  • other - The other state to subtract from this state.
§Panics
  • If self and other are dynamically-sized types and do not have the same length (for vectors) or shape (for matrices).
Source

fn mul(&self, scalar: f64) -> Self

Multiplication (self * other).

§Arguments
  • scalar - The scalar to multiply this state by.
§Returns

Product of this state with the scalar (i.e. self * scalar).

Source

fn mul_assign(&mut self, scalar: f64)

In-place multiplication (self * other).

§Arguments
  • scalar - The scalar to multiply this state by.
Source

fn get_state_variable(&self, index: StateIndex) -> f64

Get the value of the state variable at the specified index.

§Arguments
  • index - Index of the state variable to retrieve.
§Returns

Value of the state variabe at the specified index.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OdeState for f64

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for Vec<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for Mat<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for DMatrix<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for DVector<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for Array1<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl OdeState for Array2<f64>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Source§

impl<const R: usize, const C: usize> OdeState for SMatrix<f64, R, C>

Source§

fn add(&self, other: &Self) -> Self

Source§

fn add_assign(&mut self, other: &Self)

Source§

fn sub(&self, other: &Self) -> Self

Source§

fn sub_assign(&mut self, other: &Self)

Source§

fn mul(&self, scalar: f64) -> Self

Source§

fn mul_assign(&mut self, scalar: f64)

Source§

fn get_state_variable(&self, index: StateIndex) -> f64

Implementors§