Skip to main content

LinearOp

Trait LinearOp 

Source
pub trait LinearOp {
    type T: Scalar;
    type V: Vector<T = Self::T, C = Self::C>;
    type M: Matrix<T = Self::T, V = Self::V, C = Self::C>;
    type C: Context;

    // Required methods
    fn nrows(&self) -> IndexType;
    fn ncols(&self) -> IndexType;
    fn context(&self) -> &Self::C;
    fn matrix_inplace(&self, y: &mut Self::M);

    // Provided method
    fn sparsity(&self) -> Option<<Self::M as Matrix>::Sparsity> { ... }
}
Expand description

A linear operator A for use with the crate::LinearSolver trait.

This is a minimal, time-unaware description of a linear operator: it can report its shape and context, materialise itself as a matrix, and optionally provide a sparsity pattern. It is deliberately decoupled from the richer, time-aware operator traits in the diffsol crate.

A solver for Ax = b uses Self::sparsity to set up the matrix storage and Self::matrix_inplace to populate the matrix A prior to factorisation.

Required Associated Types§

Source

type T: Scalar

Source

type V: Vector<T = Self::T, C = Self::C>

Source

type M: Matrix<T = Self::T, V = Self::V, C = Self::C>

Source

type C: Context

Required Methods§

Source

fn nrows(&self) -> IndexType

Number of rows of the operator (i.e. length of the output vector y).

Source

fn ncols(&self) -> IndexType

Number of columns of the operator (i.e. length of the input vector x).

Source

fn context(&self) -> &Self::C

The context associated with this operator.

Source

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

Compute the matrix representation of the operator A and store it in y.

y is assumed to have been initialised with the sparsity pattern returned by Self::sparsity.

Provided Methods§

Source

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

The sparsity pattern of the operator’s matrix, or None if dense.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§