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§
Provided Methods§
Sourcefn apply_block(
&mut self,
x: MatRef<'_, T>,
y: MatMut<'_, T>,
) -> Result<(), OperatorError>
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
impl<T: Real, O: LinearOperator<T> + ?Sized> LinearOperator<T> for &mut O
Source§impl<T: Real> LinearOperator<T> for CscMatrix<T>
CscMatrix::gaxpy columnwise; the transpose is a dot product per
column (no transposed copy).
impl<T: Real> LinearOperator<T> for CscMatrix<T>
CscMatrix::gaxpy columnwise; the transpose is a dot product per
column (no transposed copy).
Source§impl<T: Real> LinearOperator<T> for CsrMatrix<T>
A dot product per row; the transpose scatters.
impl<T: Real> LinearOperator<T> for CsrMatrix<T>
A dot product per row; the transpose scatters.
Implementors§
impl<T, F, G> LinearOperator<T> for FnAdjointOperator<F, G>
impl<T: Real, F: FnMut(&[T], &mut [T]) -> Result<(), OperatorError>> LinearOperator<T> for FnOperator<F>
impl<T: Real, K: DenseKernel<T>> LinearOperator<T> for SymShiftInvert<T, K>
impl<T: Real> LinearOperator<T> for DenseBlock<T>
Dense, with the reference loops (fixed summation order).
impl<T: Real> LinearOperator<T> for MatRef<'_, T>
A borrowed dense matrix (zero copy from R/NumPy through xingo-ffi).