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§
Sourcefn format(&self) -> MatrixFormat
fn format(&self) -> MatrixFormat
Report the public materialization format.
Provided Methods§
Sourcefn is_real(&self) -> bool
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.
Sourcefn apply_real(&self, input: &[f64], output: &mut [f64]) -> Result<()>
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.
Sourcefn apply_transpose(
&self,
input: &[Complex64],
output: &mut [Complex64],
) -> Result<()>
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.
Sourcefn apply_adjoint(
&self,
input: &[Complex64],
output: &mut [Complex64],
) -> Result<()>
fn apply_adjoint( &self, input: &[Complex64], output: &mut [Complex64], ) -> Result<()>
Apply the conjugate transpose.
Sourcefn stored_triplets(&self) -> Result<Option<Vec<(usize, usize, Complex64)>>>
fn stored_triplets(&self) -> Result<Option<Vec<(usize, usize, Complex64)>>>
Return canonical stored nonzeros when the representation already owns them.
Sourcefn shifted_solver(
&self,
_shift: f64,
) -> Result<Option<Box<dyn ShiftedLinearSolver>>>
fn shifted_solver( &self, _shift: f64, ) -> Result<Option<Box<dyn ShiftedLinearSolver>>>
Prepare a reusable solver for (A - shift I) x = b, when supported.