コンテンツにスキップ

State

このコンテンツはまだ日本語訳がありません。

Defined in: state.rs:40

pub struct State\<const DIM: usize, const ORDER: usize\> {
pub components: [nalgebra::SVector<f64, DIM>; ORDER],
}

N-th order ODE state: ORDER vectors of DIM components each.

For a 2nd-order ODE in 3D (e.g., orbital mechanics), State<3, 2> holds [position, velocity]. For a 1D oscillator, State<1, 2> holds [x, v]. For a 1st-order ODE, State<DIM, 1> holds just [y].

components: [nalgebra::SVector<f64, DIM>; ORDER]


fn new(y: SVector<f64, DIM>, dy: SVector<f64, DIM>) -> Self

Create a new 2nd-order state from y (0th derivative) and dy (1st derivative).


fn y(&self) -> &SVector<f64, DIM>

The 0th-order component (position-like).


fn dy(&self) -> &SVector<f64, DIM>

The 1st-order component (velocity-like).


fn y_mut(&mut self) -> &mut SVector<f64, DIM>

Mutable access to the 0th-order component.


fn dy_mut(&mut self) -> &mut SVector<f64, DIM>

Mutable access to the 1st-order component.


fn from_derivative(dy: SVector<f64, DIM>, ddy: SVector<f64, DIM>) -> Self

Create a State representing a derivative (dy, ddy).

In the ODE formulation y = (q, q’), the derivative dy/dt = (q’, q”) has the same type:

  • components[0] holds dy (1st derivative)
  • components[1] holds ddy (2nd derivative)