Skip to main content

Crate ferrolearn_sparse

Crate ferrolearn_sparse 

Source
Expand description

§ferrolearn-sparse

Sparse matrix types for the ferrolearn machine learning framework.

This crate provides three sparse matrix formats:

All three types support conversion between formats, conversion to/from dense ndarray::Array2<T>, slicing, scalar multiplication, element-wise addition, and matrix-vector multiplication.

§Quick Start

use ferrolearn_sparse::{CooMatrix, CsrMatrix};

// Build in COO format, then convert.
let mut coo = CooMatrix::new(3, 3);
coo.push(0, 0, 1.0_f64);
coo.push(1, 2, 4.0);
coo.push(2, 1, 7.0);

let csr = CsrMatrix::from_coo(&coo).unwrap();
let dense = csr.to_dense();
assert_eq!(dense[[0, 0]], 1.0);
assert_eq!(dense[[1, 2]], 4.0);
assert_eq!(dense[[2, 1]], 7.0);

Re-exports§

pub use coo::CooMatrix;
pub use csc::CscMatrix;
pub use csr::CsrMatrix;

Modules§

coo
Coordinate (COO / triplet) sparse matrix format.
csc
Compressed Sparse Column (CSC) matrix format.
csr
Compressed Sparse Row (CSR) matrix format.