lazymatrix::traits
LazyMatrix for Rust · 0.8.1
rust
pub mod traitsBackend-agnostic trait surface for LazyMatrix.
The traits separate numeric operations from matrix capabilities:
Scalar— the numeric element type, a blanket-implemented bundle ofnum-traitsbounds.MatrixErrorType— the shared operational error type for a backend.MatrixShape,MatVec/MatTransposeVec, and their reusable-outputMatVecInto/MatTransposeVecIntocounterparts — the matrix-free linear-operator interface, implemented both by concrete backend matrices and byLazyMatrixitself. Products returnResult.MatVecScaledIntoandMatTransposeVecScaledIntoprovide fusedalpha/betaproducts for all supported backends andcrate::WithIntercept.MatMat/MatTransposeMatandMatMatInto/MatTransposeMatIntobatch multiple right-hand sides.MatrixReadborrows dense inputs, andMatrixOwnedselects allocating output storage.- Solver-facing vector algebra (
DotProduct,L2Norm,ScaledAddAssign, andScaleAssign). WeightedGramIntocomputes dense coefficient-space products intoMatrixWritestorage.WeightedGramKernellets backends apply normalization during accumulation to preserve small centered variations.WeightedColumnSumsIntoandWeightedColumnSumsKernelcompute stable weighted sums for intercept Gram cross terms.VectorOwnedconstructs backend-compatible coefficient scratch for lazy operator components.- The five normalization-specific vector traits (
ElemDivAssign,DotSlice,SubScalarAssign,SumEntries,ScaledSubSlice) — the elementwise primitives that fold the lazy normalization into a backend vector. They are phrased as a backend vector against a coefficient slice&[F], which is exactly the shape the centering/scaling math needs. ColumnStats— column statistics computed directly over a (possibly sparse) backend matrix, used byLazyMatrix::new.VectorView/VectorViewMut— storage-independent borrowed vector access, including strided backend views.RawColumn/RawColumnsandLogicalColumn/Columns— the backend and normalized sides of storage-independent column access.SparseColumns— the stronger borrowed access capability for contiguous sparse columns.SparseRows— borrowed access to contiguous sparse rows.MaterializeDense— explicit normalized dense materialization from any supported input.MatrixOwnedallocates the selected dense backend, andDenseNormalizepermits infallible in-place dense normalization.SubmatrixKernel— rectangular products and materialization over raw storage, used by borrowedcrate::Submatrixviews.ReadBlock— experimental fallible rectangular reads into caller-owned storage, returningDenseBlockviews without hiding I/O in borrowing.

