Crate numrs2

Crate numrs2 

Source
Expand description

§NumRS2: High-Performance Numerical Computing in Rust

NumRS2 is a comprehensive numerical computing library for Rust, inspired by NumPy. It provides a powerful N-dimensional array object, sophisticated mathematical functions, and advanced linear algebra, statistical, and random number functionality.

Version 0.1.0-beta.3 - Phase 4 Complete: Advanced features including automatic differentiation, Apache Arrow integration, randomized linear algebra, and complete sparse matrix support. Production-ready with 638 tests passing and zero warnings.

§Quick Start

use numrs2::prelude::*;

let a = Array::from_vec(vec![1.0, 2.0, 3.0, 4.0]).reshape(&[2, 2]);
let b = Array::from_vec(vec![5.0, 6.0, 7.0, 8.0]).reshape(&[2, 2]);
let c = a.matmul(&b).unwrap();
println!("Matrix multiplication result: {}", c);

§Main Features

§Core Functionality

  • N-dimensional Array: Core Array type with efficient memory layout and broadcasting
  • Advanced Linear Algebra:
    • Matrix operations, decompositions, solvers through BLAS/LAPACK integration
    • Sparse matrices (COO, CSR, CSC, DIA formats) with iterative solvers
    • Randomized algorithms (randomized SVD, random projections)
  • Automatic Differentiation: Forward and reverse mode AD with higher-order derivatives
  • Data Interoperability:
    • Apache Arrow integration for zero-copy data exchange (requires arrow feature)
    • Python bindings via PyO3 for NumPy compatibility (requires python feature)
    • Feather format support for fast columnar storage

§Performance Features

  • Expression Templates: Lazy evaluation and operation fusion
  • Advanced Indexing: Fancy indexing, boolean masking, conditional selection
  • SIMD Acceleration: Vectorized math operations using SIMD instructions
  • Parallel Computing: Multi-threaded execution with Rayon
  • GPU Acceleration: Optional GPU-accelerated operations using WGPU (requires gpu feature)

§Additional Capabilities

  • Mathematical Functions: Comprehensive set of element-wise mathematical operations
  • Random Number Generation: Modern interface for various distributions
  • Statistical Analysis: Descriptive statistics and probability distributions
  • Type Safety: Leverage Rust’s type system for compile-time guarantees

§Optional Features

  • arrow: Apache Arrow integration for zero-copy data exchange
  • python: Python bindings via PyO3 for NumPy interoperability
  • lapack: LAPACK-dependent linear algebra operations
  • gpu: GPU acceleration using WGPU
  • matrix_decomp: Matrix decomposition functions (enabled by default)
  • validation: Additional runtime validation checks

Re-exports§

pub use error::NumRs2Error;
pub use error::Result;
pub use random::random_base;

Modules§

algorithms
High-performance numerical algorithms
array
array_ops
array_ops_legacy
arrays
Array operations and data structures
autodiff
Automatic Differentiation for NumRS2
axis_ops
bitwise_ops
Bitwise operations for Arrays
blas
char
String and character array operations (NumPy char module equivalent)
comparisons
comparisons_broadcast
Comparison operators with automatic broadcasting
complex_ops
Complex number operations for Arrays
conversions
error
NumRS2 Error System
error_handling
Error handling configuration for NumRS2
expr
Expression Templates for Lazy Evaluation
financial
Financial Functions Module
indexing
interop
Interoperability with other Rust numerical libraries
io
linalg
Basic linear algebra operations with Array Includes matrix multiplication, dot product, matrix inversion, etc.
linalg_extended
Extended Linear Algebra Operations
linalg_optimized
Optimized linear algebra operations with enhanced performance algorithms
linalg_parallel
Parallel linear algebra operations with load balancing
linalg_stable
Numerically stable matrix decomposition algorithms
masked
math
math_extended
Extended Mathematical Functions
matrix
memory_alloc
Custom memory allocation for numerical workloads
memory_optimize
Memory layout optimization for cache efficiency
mmap
new_modulesDeprecated
optimized_ops
Optimized operations using scirs2-core features
parallel
Parallel processing enhancements and workload balancing
parallel_optimize
Parallel processing optimization
prelude
Core prelude that exports the most commonly used types and functions
printing
Array Printing and Display Module
random
Random Number Generation
set_ops
Set operations for arrays
signal
Signal Processing Module
simd
simd_optimize
CPU feature detection and SIMD optimization for NumRS
sparse
Sparse Matrix Operations
sparse_enhanced
Enhanced sparse matrix operations with advanced algorithms and optimizations
stats
stride_tricks
testing
Testing Utilities for NumRS2
traits
Core Trait System for NumRS2
types
Advanced data types and type system for NumRS
ufuncs
unique
unique_optimized
util
views

Macros§

error_location
Macro for creating error location from current position
operation_context
Macro for creating operation context with current function
run_tests
Convenience macro for running multiple test assertions
simd_array
Convenience macro for creating SIMD-optimized arrays