#linear-algebra #matrix-operations #sparse-matrix #machine-learning #analysis #convenience #svd

single_algebra

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

24 releases

new 0.2.3-alpha.0 Mar 17, 2025
0.2.2-alpha.0 Mar 6, 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

#294 in Math

Download history 2/week @ 2024-12-01 18/week @ 2024-12-08 508/week @ 2024-12-22 13/week @ 2024-12-29 3/week @ 2025-01-05 1/week @ 2025-01-12 326/week @ 2025-01-19 356/week @ 2025-01-26 437/week @ 2025-02-02 92/week @ 2025-02-09 120/week @ 2025-02-16 15/week @ 2025-02-23 396/week @ 2025-03-02 56/week @ 2025-03-09 99/week @ 2025-03-16

570 downloads per month
Used in single_rust

Custom license

250KB
5.5K 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

~11–46MB
~685K SLoC