#matrix #linear-algebra #dimensionality-reduction #operation #svd #cluster-analysis #science #machine-learning #inference

single_algebra

A linear algebra convenience library for the single-rust library. Can be used externally as well.

29 releases

new 0.3.0-alpha.1 Apr 15, 2025
0.2.3-alpha.3 Mar 27, 2025
0.2.0-alpha.0 Feb 15, 2025
0.1.2-alpha.7 Feb 5, 2025
0.1.0-alpha.3 Sep 10, 2024

#723 in Math

Download history 41/week @ 2024-12-26 2/week @ 2025-01-02 2/week @ 2025-01-09 189/week @ 2025-01-16 271/week @ 2025-01-23 521/week @ 2025-01-30 155/week @ 2025-02-06 186/week @ 2025-02-13 19/week @ 2025-02-20 197/week @ 2025-02-27 255/week @ 2025-03-06 106/week @ 2025-03-13 26/week @ 2025-03-20 368/week @ 2025-03-27 14/week @ 2025-04-03 133/week @ 2025-04-10

546 downloads per month
Used in single_rust

Custom license

260KB
6K SLoC

single-algebra 🧮

The companion algebra library for single-rust, providing powerful matrix operations and machine learning utilities.

Features 🚀

  • Efficient operations on sparse and dense matrices
  • Dimensionality reduction techniques
  • Clustering algorithms including Louvain community detection
  • Batch processing utilities with masking support
  • Statistical analysis and inference
  • More features planned!

Matrix Operations 📊

  • SVD decomposition with parallel and LAPACK implementations
  • Matrix convenience functions for statistical operations
  • Support for both CSR and CSC sparse matrix formats
  • Masked operations for selective data processing
  • Batch-wise statistics (mean, variance) with flexible batch identifiers

Clustering 🔍

  • Louvain community detection
  • Similarity network construction
  • K-nearest neighbors graph building
  • Local moving algorithm for community refinement
  • Leiden clustering implementation (work in progress)

Dimensionality Reduction ⬇️

  • Incremental PCA implementation
  • Support for sparse matrices in dimensionality reduction
  • SVD-based compression and analysis

Statistical Analysis 📈

  • Multiple testing correction methods
  • Parametric and non-parametric hypothesis testing
  • Effect size calculations
  • Batch-wise statistical comparisons

Installation

Add this to your Cargo.toml:

[dependencies]
single-algebra = "0.2.2-alpha.0"

Batch Processing

The library now includes flexible batch processing capabilities with the BatchIdentifier trait, which supports common identifier types:

  • String and string slices
  • Integer types (i32, u32, usize)
  • Custom types (by implementing the trait)
// Example of batch-wise statistics
let batches = vec!["batch1", "batch2", "batch3"];
let batch_means = matrix.mean_batch_col(&batches)?;

Masked Operations

Selective processing is now available through masked operations:

// Only process selected columns
let mask = vec![true, false, true, true, false];
let masked_sums = matrix.sum_col_masked(&mask)?;

Acknowledgments 🙏

The Louvain clustering implementation was adapted from louvain-rs written by Juan Morales (crispamares@gmail.com). The original implementation has been modified to better suit the needs of single-algebra.

Dependencies

~13–48MB
~726K SLoC