Preserve sparse storage
Apply centering and scaling through matrix operations without turning structural zeros into stored entries.
Normalized design matrices for Rust. Keep sparse matrices sparse, reuse fitted parameters, and choose when to materialize.
LazyMatrix represents
without storing the centered matrix. Here,
cargo add lazymatrix --features ndarray
cargo add ndarray@0.17use lazymatrix::{Centering, LazyMatrix, MatVec, Normalization, Scaling};
use ndarray::array;
let x = array![[1.0, 0.0], [2.0, 3.0], [0.0, 4.0]];
let lazy = LazyMatrix::new(
x.view(),
Normalization::new(Centering::Mean, Scaling::Sd),
).unwrap();
let y = lazy.matvec(&array![1.0, -1.0]).unwrap();Read the guide for installation and eager conversion, or see how it works for the normalization identities. The benchmark comparisons explain the costs of construction, repeated operations, and additional memory.
LazyMatrix is in early development, and breaking changes are expected. Find releases on crates.io and source code on GitHub.