Skip to main content

LinearOperator

Trait LinearOperator 

Source
pub trait LinearOperator: Send + Sync {
    // Required methods
    fn shape(&self) -> (usize, usize);
    fn format(&self) -> MatrixFormat;
    fn apply(&self, input: &[Complex64], output: &mut [Complex64]) -> Result<()>;

    // Provided methods
    fn is_real(&self) -> bool { ... }
    fn apply_real(&self, input: &[f64], output: &mut [f64]) -> Result<()> { ... }
    fn apply_transpose(
        &self,
        input: &[Complex64],
        output: &mut [Complex64],
    ) -> Result<()> { ... }
    fn apply_adjoint(
        &self,
        input: &[Complex64],
        output: &mut [Complex64],
    ) -> Result<()> { ... }
    fn stored_triplets(&self) -> Result<Option<Vec<(usize, usize, Complex64)>>> { ... }
    fn shifted_solver(
        &self,
        _shift: f64,
    ) -> Result<Option<Box<dyn ShiftedLinearSolver>>> { ... }
}
Expand description

Rectangular-capable narrow waist shared by stored and matrix-free maps.

Required Methods§

Source

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

Return (rows, columns).

Source

fn format(&self) -> MatrixFormat

Report the public materialization format.

Source

fn apply(&self, input: &[Complex64], output: &mut [Complex64]) -> Result<()>

Compute output = A * input.

Implementations validate both vector lengths and overwrite every output element.

Provided Methods§

Source

fn is_real(&self) -> bool

Whether this operator preserves real vectors exactly.

Eigensolvers use this capability to retain the public complex-valued interface while avoiding complex arithmetic for real Hamiltonians.

Source

fn apply_real(&self, input: &[f64], output: &mut [f64]) -> Result<()>

Apply this operator to a real vector.

Custom operators can opt into the real fast path by overriding LinearOperator::is_real and this method. The compatibility fallback remains correct, but stored operators provide an allocation-free implementation below.

Source

fn apply_transpose( &self, input: &[Complex64], output: &mut [Complex64], ) -> Result<()>

Apply the algebraic transpose without conjugating either operand.

Stored operators use their canonical triplets directly. A genuinely matrix-free implementation may override this method; the default falls back to column actions without ever retaining a full square matrix.

Source

fn apply_adjoint( &self, input: &[Complex64], output: &mut [Complex64], ) -> Result<()>

Apply the conjugate transpose.

Source

fn stored_triplets(&self) -> Result<Option<Vec<(usize, usize, Complex64)>>>

Return canonical stored nonzeros when the representation already owns them.

Source

fn shifted_solver( &self, _shift: f64, ) -> Result<Option<Box<dyn ShiftedLinearSolver>>>

Prepare a reusable solver for (A - shift I) x = b, when supported.

Implementors§