pub struct Operator;Expand description
Sparse finite-difference operator assembly.
Implementations§
Source§impl Operator
impl Operator
Sourcepub fn compute_state_derivatives<const N: usize>(
grid: &Grid<N>,
v: &[f64],
) -> Vec<StateDerivatives<N>>
pub fn compute_state_derivatives<const N: usize>( grid: &Grid<N>, v: &[f64], ) -> Vec<StateDerivatives<N>>
Computes first and diagonal second derivatives of v on grid.
Uses central second differences on interior nodes and one-sided first
differences on boundaries. This is the derivative bundle consumed by
crate::models::control::ControlProblem::driver.
Sourcepub fn initialize_matrix<const N: usize>(grid: &Grid<N>) -> CsrMatrix
pub fn initialize_matrix<const N: usize>(grid: &Grid<N>) -> CsrMatrix
Creates a CSR matrix with the sparsity pattern of the FD transport
operator on grid.
Each row has up to one forward and one backward entry per dimension, plus the diagonal. Entries are initialized to zero except the diagonal, which starts at one.
Sourcepub fn update_matrix<const N: usize>(
mat: &mut CsrMatrix,
dt: f64,
grid: &Grid<N>,
transports: &[Transport<N>],
discount_rates: &[f64],
)
pub fn update_matrix<const N: usize>( mat: &mut CsrMatrix, dt: f64, grid: &Grid<N>, transports: &[Transport<N>], discount_rates: &[f64], )
Updates an existing CSR matrix to I - dt * transport.
The forward and backward entries are populated with -dt * plus[dim]
and -dt * minus[dim], and the diagonal is 1 + dt * (sum of transport rates) + dt * discount_rate.
Auto Trait Implementations§
impl Freeze for Operator
impl RefUnwindSafe for Operator
impl Send for Operator
impl Sync for Operator
impl Unpin for Operator
impl UnsafeUnpin for Operator
impl UnwindSafe for Operator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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