Trait LinearOperator

Source
pub trait LinearOperator<F: Float> {
    // Required methods
    fn shape(&self) -> (usize, usize);
    fn matvec(&self, x: &[F]) -> SparseResult<Vec<F>>;

    // Provided methods
    fn matmat(&self, x: &[Vec<F>]) -> SparseResult<Vec<Vec<F>>> { ... }
    fn rmatvec(&self, _x: &[F]) -> SparseResult<Vec<F>> { ... }
    fn rmatmat(&self, x: &[Vec<F>]) -> SparseResult<Vec<Vec<F>>> { ... }
    fn has_adjoint(&self) -> bool { ... }
}
Expand description

Trait for representing a linear operator

This trait provides an abstract interface for linear operators, allowing matrix-free implementations and compositions.

Required Methods§

Source

fn shape(&self) -> (usize, usize)

The shape of the operator (rows, columns)

Source

fn matvec(&self, x: &[F]) -> SparseResult<Vec<F>>

Apply the operator to a vector: y = A * x

Provided Methods§

Source

fn matmat(&self, x: &[Vec<F>]) -> SparseResult<Vec<Vec<F>>>

Apply the operator to a matrix: Y = A * X where X is column-major (each column is a vector)

Source

fn rmatvec(&self, _x: &[F]) -> SparseResult<Vec<F>>

Apply the adjoint of the operator to a vector: y = A^H * x Default implementation returns an error

Source

fn rmatmat(&self, x: &[Vec<F>]) -> SparseResult<Vec<Vec<F>>>

Apply the adjoint of the operator to a matrix: Y = A^H * X Default implementation calls rmatvec for each column

Source

fn has_adjoint(&self) -> bool

Check if the operator supports adjoint operations

Implementors§