Trait LinearOp

Source
pub trait LinearOp: Op {
    // Required method
    fn gemv_inplace(
        &self,
        x: &Self::V,
        t: Self::T,
        beta: Self::T,
        y: &mut Self::V,
    );

    // Provided methods
    fn call_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::V) { ... }
    fn matrix(&self, t: Self::T) -> Self::M { ... }
    fn matrix_inplace(&self, t: Self::T, y: &mut Self::M) { ... }
    fn _default_matrix_inplace(&self, t: Self::T, y: &mut Self::M) { ... }
    fn sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity> { ... }
}
Expand description

LinearOp is a trait for linear operators (i.e. they only depend linearly on the input x), see crate::NonLinearOp for a non-linear op.

An example of a linear operator is a matrix-vector product y = A(t) * x, where A(t) is a matrix. It extends the Op trait with methods for calling the operator via a GEMV-like operation (i.e. y = t * A * x + beta * y), and for computing the matrix representation of the operator.

Required Methods§

Source

fn gemv_inplace(&self, x: &Self::V, t: Self::T, beta: Self::T, y: &mut Self::V)

Compute the operator via a GEMV operation (i.e. y = A(t) * x + beta * y)

Provided Methods§

Source

fn call_inplace(&self, x: &Self::V, t: Self::T, y: &mut Self::V)

Compute the operator y = A(t) * x at a given state and time, the default implementation uses Self::gemv_inplace.

Source

fn matrix(&self, t: Self::T) -> Self::M

Compute the matrix representation of the operator A(t) and return it. See Self::matrix_inplace for a non-allocating version.

Source

fn matrix_inplace(&self, t: Self::T, y: &mut Self::M)

Compute the matrix representation of the operator A(t) and store it in the matrix y. The default implementation of this method computes the matrix using Self::gemv_inplace, but it can be overriden for more efficient implementations.

Source

fn _default_matrix_inplace(&self, t: Self::T, y: &mut Self::M)

Default implementation of the matrix computation, see Self::matrix_inplace.

Source

fn sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Implementations on Foreign Types§

Source§

impl<C: LinearOp> LinearOp for &C

Source§

fn gemv_inplace(&self, x: &Self::V, t: Self::T, beta: Self::T, y: &mut Self::V)

Source§

fn sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity>

Source§

fn matrix_inplace(&self, t: Self::T, y: &mut Self::M)

Implementors§

Source§

impl<C: NonLinearOpJacobian> LinearOp for LinearisedOp<C>

Source§

impl<Eqn> LinearOp for AdjointMass<'_, Eqn>

Source§

impl<M, F> LinearOp for ParameterisedOp<'_, LinearClosure<M, F>>
where M: Matrix, F: Fn(&M::V, &M::V, M::T, M::T, &mut M::V),

Source§

impl<M, F, G> LinearOp for ParameterisedOp<'_, LinearClosureWithAdjoint<M, F, G>>
where M: Matrix, F: Fn(&M::V, &M::V, M::T, M::T, &mut M::V), G: Fn(&M::V, &M::V, M::T, M::T, &mut M::V),

Source§

impl<M: Matrix> LinearOp for MatrixOp<M>

Source§

impl<M: Matrix> LinearOp for ParameterisedOp<'_, UnitCallable<M>>

Source§

impl<M: Matrix> LinearOp for UnitCallable<M>

Source§

impl<M: MatrixHost<T = T>, CG: CodegenModule> LinearOp for DiffSlMass<'_, M, CG>