Expand description
Sparse matrix integration with ndarray types.
This module provides conversion functions between ndarray dense matrices and OxiBLAS sparse matrix formats (CSR, CSC), plus sparse linear algebra operations that accept and return ndarray types.
§Features
- Conversions: Dense (Array2) to/from CSR and CSC sparse formats
- SpMV: Sparse matrix-vector multiplication returning Array1
- Sparse Solve: Solve sparse linear systems using CG, returning Array1
§Example
use ndarray::array;
use oxiblas_ndarray::sparse::{array2_to_csr, spmv_ndarray};
let dense = array![[1.0, 0.0, 2.0], [0.0, 3.0, 0.0], [4.0, 0.0, 5.0]];
let csr = array2_to_csr(&dense);
assert_eq!(csr.nnz(), 5);
let x = array![1.0, 1.0, 1.0];
let y = spmv_ndarray(&csr, &x);
assert_eq!(y, array![3.0, 3.0, 9.0]);Enums§
- Sparse
Ndarray Error - Error type for sparse ndarray operations.
Functions§
- array2_
to_ csc - Converts a dense Array2 to CSC (Compressed Sparse Column) format using exact-zero sparsification.
- array2_
to_ csc_ with_ tolerance - Converts a dense Array2 to CSC (Compressed Sparse Column) format, with an explicit, opt-in tolerance for approximate sparsification.
- array2_
to_ csr - Converts a dense Array2 to CSR (Compressed Sparse Row) format using exact-zero sparsification.
- array2_
to_ csr_ with_ tolerance - Converts a dense Array2 to CSR (Compressed Sparse Row) format, with an explicit, opt-in tolerance for approximate sparsification.
- csc_
to_ array2 - Converts a CSC matrix back to a dense Array2.
- csr_
to_ array2 - Converts a CSR matrix back to a dense Array2.
- sparse_
solve_ ndarray - Solve a sparse linear system A * x = b using Conjugate Gradient.
- sparse_
solve_ ndarray_ with_ options - Solve a sparse linear system with custom tolerance and max iterations.
- spmv_
full_ ndarray - Sparse matrix-vector multiplication with scaling: y = alpha * A * x + beta * y
- spmv_
ndarray - Sparse matrix-vector multiplication: y = A * x