Skip to main content

SparseOps

Trait SparseOps 

Source
pub trait SparseOps {
    // Required methods
    fn spmv(
        &self,
        alpha: f32,
        x: &[f32],
        beta: f32,
        y: &mut [f32],
    ) -> Result<(), SparseError>;
    fn spmm(
        &self,
        alpha: f32,
        b: &[f32],
        b_cols: usize,
        beta: f32,
        c: &mut [f32],
    ) -> Result<(), SparseError>;
}
Expand description

Sparse matrix operations trait.

Provides SpMV and SpMM with provable error bounds.

Required Methods§

Source

fn spmv( &self, alpha: f32, x: &[f32], beta: f32, y: &mut [f32], ) -> Result<(), SparseError>

Sparse matrix-vector multiply: y = α * A * x + β * y

§Contract: sparse-spmv-v1.yaml / spmv

Preconditions: x.len() == self.cols(), y.len() == self.rows() Postcondition: backward error ≤ nnz_per_row * f32::EPSILON * ||A||_inf * ||x||_inf

§Errors

Returns error on dimension mismatch.

Source

fn spmm( &self, alpha: f32, b: &[f32], b_cols: usize, beta: f32, c: &mut [f32], ) -> Result<(), SparseError>

Sparse matrix-dense matrix multiply: C = α * A * B + β * C

B is row-major with b_cols columns. C is row-major with b_cols columns.

§Errors

Returns error on dimension mismatch.

Implementors§