Skip to main content

SparseLuKernels

Trait SparseLuKernels 

Source
pub trait SparseLuKernels<R: Runtime> {
    // Required methods
    fn scatter_column(
        &self,
        values: &[f64],
        row_indices: &[i64],
        work: &mut [f64],
    );
    fn sparse_axpy(
        &self,
        scale: f64,
        values: &[f64],
        row_indices: &[i64],
        work: &mut [f64],
    );
    fn find_pivot(&self, work: &[f64], start: usize, end: usize) -> (usize, f64);
    fn gather_and_clear(
        &self,
        work: &mut [f64],
        row_indices: &[i64],
        output: &mut [f64],
    );
    fn divide_by_pivot(&self, work: &mut [f64], row_indices: &[i64], pivot: f64);
    fn swap_rows(
        &self,
        work: &mut [f64],
        perm: &mut [usize],
        row_a: usize,
        row_b: usize,
    );
}
Expand description

Low-level kernel operations for sparse LU

These are the primitive operations that benefit from SIMD/GPU acceleration. Higher-level factorization algorithms compose these kernels.

Required Methods§

Source

fn scatter_column(&self, values: &[f64], row_indices: &[i64], work: &mut [f64])

Scatter sparse column into dense work vector

work[row_indices[i]] = values[i] for i in 0..nnz

§Arguments
  • values - Sparse column values
  • row_indices - Row indices for each value
  • work - Dense work vector (length n), modified in place
Source

fn sparse_axpy( &self, scale: f64, values: &[f64], row_indices: &[i64], work: &mut [f64], )

Sparse AXPY: work[indices] -= scale * values

For each i: work[row_indices[i]] -= scale * values[i]

§Arguments
  • scale - Scalar multiplier
  • values - Sparse vector values
  • row_indices - Row indices for each value
  • work - Dense work vector, modified in place
Source

fn find_pivot(&self, work: &[f64], start: usize, end: usize) -> (usize, f64)

Find index of maximum absolute value in work[start..end]

Returns (index, max_abs_value) where index is in [start, end)

§Arguments
  • work - Dense work vector
  • start - Start index (inclusive)
  • end - End index (exclusive)
Source

fn gather_and_clear( &self, work: &mut [f64], row_indices: &[i64], output: &mut [f64], )

Gather nonzeros from work vector into sparse output

output[i] = work[row_indices[i]] for i in 0..nnz Then: work[row_indices[i]] = 0.0 (clear for next column)

§Arguments
  • work - Dense work vector, cleared after gather
  • row_indices - Row indices to gather
  • output - Output sparse values
Source

fn divide_by_pivot(&self, work: &mut [f64], row_indices: &[i64], pivot: f64)

Divide work vector elements by pivot

work[row_indices[i]] /= pivot for i in 0..nnz

§Arguments
  • work - Dense work vector, modified in place
  • row_indices - Row indices to divide
  • pivot - Pivot value to divide by
Source

fn swap_rows( &self, work: &mut [f64], perm: &mut [usize], row_a: usize, row_b: usize, )

Swap two rows in permutation and work vector

§Arguments
  • work - Dense work vector
  • perm - Row permutation array
  • row_a - First row index
  • row_b - Second row index

Implementors§