Skip to main content

LinearOperator

Trait LinearOperator 

Source
pub trait LinearOperator<T: Real = f64> {
    // Required methods
    fn nrows(&self) -> usize;
    fn ncols(&self) -> usize;
    fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>;

    // Provided method
    fn apply_block(
        &mut self,
        x: MatRef<'_, T>,
        y: MatMut<'_, T>,
    ) -> Result<(), OperatorError> { ... }
}
Expand description

y ← A x for an nrows × ncols operator known only by its action.

&mut self because the useful operators keep state: a closure that counts calls, a shift-invert operator whose Lu::ftran needs &mut, a workspace. Fallible because a user’s solve can fail and the crate promises errors, not panics. The drivers call apply with x.len() == ncols() and y.len() == nrows() — implementors may rely on it. y is overwritten (not accumulated).

Required Methods§

Source

fn nrows(&self) -> usize

Rows of A (length of y).

Source

fn ncols(&self) -> usize

Columns of A (length of x).

Source

fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

y ← A x.

§Errors

Whatever the operator reports.

Provided Methods§

Source

fn apply_block( &mut self, x: MatRef<'_, T>, y: MatMut<'_, T>, ) -> Result<(), OperatorError>

Y ← A X for a block of columns; the default loops over LinearOperator::apply. Dense and sparse implementations override it (one pass over A for l columns — the cost that matters in crate::rsvd()).

§Errors

Whatever the operator reports; an OperatorError if the shapes of X and Y do not match the operator.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: Real, O: LinearOperator<T> + ?Sized> LinearOperator<T> for &mut O

Source§

fn nrows(&self) -> usize

Source§

fn ncols(&self) -> usize

Source§

fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

Source§

fn apply_block( &mut self, x: MatRef<'_, T>, y: MatMut<'_, T>, ) -> Result<(), OperatorError>

Source§

impl<T: Real> LinearOperator<T> for CscMatrix<T>

CscMatrix::gaxpy columnwise; the transpose is a dot product per column (no transposed copy).

Source§

fn nrows(&self) -> usize

Source§

fn ncols(&self) -> usize

Source§

fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

Source§

impl<T: Real> LinearOperator<T> for CsrMatrix<T>

A dot product per row; the transpose scatters.

Source§

fn nrows(&self) -> usize

Source§

fn ncols(&self) -> usize

Source§

fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

Implementors§

Source§

impl<T, F, G> LinearOperator<T> for FnAdjointOperator<F, G>
where T: Real, F: FnMut(&[T], &mut [T]) -> Result<(), OperatorError>,

Source§

impl<T: Real, F: FnMut(&[T], &mut [T]) -> Result<(), OperatorError>> LinearOperator<T> for FnOperator<F>

Source§

impl<T: Real, K: DenseKernel<T>> LinearOperator<T> for SymShiftInvert<T, K>

Source§

impl<T: Real> LinearOperator<T> for DenseBlock<T>

Dense, with the reference loops (fixed summation order).

Source§

impl<T: Real> LinearOperator<T> for MatRef<'_, T>

A borrowed dense matrix (zero copy from R/NumPy through xingo-ffi).

Source§

impl<T: Real> LinearOperator<T> for ShiftInvert<T>