#artificial-intelligence #scientific #scipy #science

scirs2

A Rust port of SciPy with AI/ML extensions - Scientific Computing and AI Library (scirs2)

10 releases

new 0.2.0 Feb 15, 2026
0.1.3 Jan 26, 2026
0.1.1 Dec 30, 2025
0.1.0-rc.2 Oct 19, 2025
0.1.0-alpha.6 Jun 25, 2025

#1436 in Math

Download history 221/week @ 2025-10-20 105/week @ 2025-10-27 99/week @ 2025-11-03 99/week @ 2025-11-10 122/week @ 2025-11-17 103/week @ 2025-11-24 108/week @ 2025-12-01 83/week @ 2025-12-08 141/week @ 2025-12-15 137/week @ 2025-12-22 29/week @ 2025-12-29 14/week @ 2026-01-05 132/week @ 2026-01-12 126/week @ 2026-01-19 52/week @ 2026-01-26 28/week @ 2026-02-02

342 downloads per month

Apache-2.0

26MB
527K SLoC

SciRS2: Scientific Computing in Rust

crates.io License Documentation

SciRS2 is a comprehensive scientific computing library for Rust, inspired by SciPy and designed to provide a complete ecosystem for numerical computation, statistical analysis, and scientific algorithms.

Important: From v0.1.5, SciRS2 follows the SciRS2 POLICY for consistent ecosystem architecture with layered abstractions.

Overview

This is the main SciRS2 crate, which provides a convenient facade over the ecosystem of specialized sub-crates. Each sub-crate focuses on a specific domain of scientific computing, while this crate re-exports their functionality in a unified interface.

Features

SciRS2 brings together a large collection of scientific computing tools:

  • Core Utilities: Common functionality through scirs2-core
  • Linear Algebra: Matrix operations, decompositions, and solvers via scirs2-linalg
  • Statistics: Distributions, hypothesis testing, and statistical functions in scirs2-stats
  • Optimization: Minimization, root finding, and curve fitting with scirs2-optimize
  • Integration: Numerical integration and ODE solvers through scirs2-integrate
  • Interpolation: Various interpolation methods in scirs2-interpolate
  • Special Functions: Mathematical special functions via scirs2-special
  • Fourier Analysis: FFT and related transforms in scirs2-fft
  • Signal Processing: Filtering, convolution, and spectral analysis in scirs2-signal
  • Sparse Matrices: Efficient sparse matrix formats and operations via scirs2-sparse
  • Spatial Algorithms: Spatial data structures and algorithms in scirs2-spatial
  • Image Processing: Multidimensional image processing in scirs2-ndimage
  • Machine Learning: Clustering, metrics, and neural networks via multiple sub-crates
  • Data I/O: Reading and writing various scientific data formats via scirs2-io
  • And more: Various additional modules for specific applications

Installation

Add the following to your Cargo.toml:

[dependencies]
scirs2 = "0.1.5"  # Main package with default features

You can enable only the features you need:

[dependencies]
scirs2 = { version = "0.1.5", features = ["linalg", "stats", "optimize"] }

Or use specific modules directly:

[dependencies]
scirs2-core = "0.1.5"
scirs2-linalg = "0.1.5"
scirs2-stats = "0.1.5"

Basic usage examples:

use scirs2::prelude::*;
use ndarray::array;

fn main() -> CoreResult<()> {
    // Linear algebra operations
    let a = array![[1., 2.], [3., 4.]];
    let eig = linalg::eigen::eig(&a)?;
    println!("Eigenvalues: {:?}", eig.eigenvalues);
    println!("Eigenvectors: {:?}", eig.eigenvectors);
    
    // Statistical distributions
    let normal = stats::distributions::normal::Normal::new(0.0, 1.0)?;
    let samples = normal.random_sample(1000, None)?;
    let mean = stats::descriptive::mean(&samples)?;
    let std_dev = stats::descriptive::std_dev(&samples, None)?;
    println!("Sample mean: {}, std dev: {}", mean, std_dev);
    
    // Optimization
    let f = |x: &[f64]| x[0].powi(2) + x[1].powi(2);
    let df = |x: &[f64], grad: &mut [f64]| {
        grad[0] = 2.0 * x[0];
        grad[1] = 2.0 * x[1];
    };
    let result = optimize::unconstrained::minimize(
        f, df, &[1.0, 1.0], "L-BFGS-B", None, None)?;
    println!("Optimization result: {:?}", result);
    
    // Special functions
    let gamma = special::gamma::gamma(5.0)?;
    println!("Gamma(5) = {}", gamma);
    
    // FFT
    let signal = array![1.0, 2.0, 3.0, 4.0];
    let fft_result = fft::fft(&signal)?;
    println!("FFT result: {:?}", fft_result);
    
    Ok(())
}

Feature Flags

This crate uses feature flags to control which sub-crates are included:

  • core: Core utilities (always enabled)
  • linalg: Linear algebra operations
  • stats: Statistical functions and distributions
  • optimize: Optimization algorithms
  • integrate: Numerical integration and ODEs
  • interpolate: Interpolation methods
  • fft: Fast Fourier Transform
  • special: Special functions
  • signal: Signal processing
  • sparse: Sparse matrices
  • spatial: Spatial algorithms
  • ndimage: N-dimensional image processing
  • cluster: Clustering algorithms
  • datasets: Dataset utilities
  • io: I/O utilities
  • neural: Neural networks
  • graph: Graph algorithms
  • transform: Data transformation
  • metrics: Evaluation metrics
  • text: Text processing
  • vision: Computer vision
  • series: Time series analysis
  • autograd: Automatic differentiation

Architecture

SciRS2 follows a modular architecture where each domain of scientific computing is implemented in a separate crate. This main crate provides a unified interface by re-exporting their functionality.

SciRS2 POLICY

Starting with v0.1.5, SciRS2 follows a strict layered architecture:

  • Core-Only Dependencies: Only scirs2-core uses external dependencies directly
  • Unified Abstractions: All other crates use scirs2-core abstractions for rand, ndarray, etc.
  • Ecosystem Consistency: Ensures consistent APIs, centralized version control, and type safety
  • Performance Benefits: Enables better optimization through centralized abstractions

See the SciRS2 Ecosystem Policy for complete details.

Architecture Benefits

  • Modular Development: Each domain can be developed and tested independently
  • Reduced Compilation Time: Users can include only the features they need
  • Flexible Dependencies: Sub-crates can have different dependency requirements
  • Focused Documentation: Each domain has its own focused documentation
  • Consistent API: Unified interfaces through scirs2-core abstractions

Module Structure

scirs2
├── core       // Core utilities
├── linalg     // Linear algebra
├── stats      // Statistics
├── optimize   // Optimization
├── integrate  // Integration
├── interpolate // Interpolation
├── fft        // Fourier transforms
├── special    // Special functions
├── signal     // Signal processing
├── sparse     // Sparse matrices
├── spatial    // Spatial algorithms
├── ndimage    // Image processing
└── ...        // Other modules

Performance

SciRS2 is designed with performance in mind:

  • Uses optimized BLAS and LAPACK implementations where appropriate
  • Leverages SIMD operations when available
  • Provides parallel processing capabilities
  • Uses memory-efficient algorithms
  • Employs caching for expensive computations

Contributing

See the CONTRIBUTING.md file for contribution guidelines.

License

This project is Licensed under the Apache License 2.0. See LICENSE for details.

You can choose to use either license. See the LICENSE file for details.

Dependencies

~9–36MB
~559K SLoC