Skip to main content

KLinOp

Trait KLinOp 

Source
pub trait KLinOp: Send + Sync {
    type Scalar: KrystScalar;

    // Required methods
    fn dims(&self) -> (usize, usize);
    fn matvec_s(
        &self,
        x: &[Self::Scalar],
        y: &mut [Self::Scalar],
        scratch: &mut BridgeScratch,
    );

    // Provided methods
    fn supports_t_matvec_s(&self) -> bool { ... }
    fn t_matvec_s(
        &self,
        _x: &[Self::Scalar],
        _y: &mut [Self::Scalar],
        _scratch: &mut BridgeScratch,
    ) { ... }
}
Expand description

Internal, scalar-generic linear operator for solvers.

Forward-looking notes:

  • Additional operator kinds (transpose/adjoint, batched calls) can be added later without breaking object safety.
  • When the public API becomes scalar generic, this trait can be re-exported directly.

Required Associated Types§

Required Methods§

Source

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

Dimensions of the operator (nrows, ncols).

Source

fn matvec_s( &self, x: &[Self::Scalar], y: &mut [Self::Scalar], scratch: &mut BridgeScratch, )

Perform y <- A x.

scratch allows adapters to reuse temporary buffers when bridging between scalar types. Native-S implementations may ignore it.

Provided Methods§

Source

fn supports_t_matvec_s(&self) -> bool

Whether the operator exposes a transpose/adjoint matvec.

Examples found in repository?
examples/complex_matrix_market_demo.rs (line 1803)
1802        fn supports_t_matvec_s(&self) -> bool {
1803            self.base.supports_t_matvec_s()
1804        }
Source

fn t_matvec_s( &self, _x: &[Self::Scalar], _y: &mut [Self::Scalar], _scratch: &mut BridgeScratch, )

Perform y <- A^T x (or A^H x in complex builds).

Default implementation panics unless overridden by operators that advertise transpose support via supports_t_matvec_s.

Examples found in repository?
examples/complex_matrix_market_demo.rs (line 1807)
1806        fn t_matvec_s(&self, x: &[S], y: &mut [S], scratch: &mut BridgeScratch) {
1807            self.base.t_matvec_s(x, y, scratch);
1808        }

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl KLinOp for DistCsrOp

Source§

impl KLinOp for GenericCsrOp<Complex64>

Available on crate features backend-faer and complex only.
Source§

impl<T> KLinOp for T
where T: LinOpF64 + LinOp<S = f64> + Send + Sync,

Blanket implementation for native f64 operators.

Complex scalar solvers should wrap real backends via [crate::ops::wrap::F64AsSOp] instead of relying on this impl.