sparse-ir 0.11.0

Rust implementation of SparseIR functionality
Documentation

sparse-ir

Crates.io Documentation License: MIT OR Apache-2.0

A high-performance Rust implementation of the SparseIR (Sparse Intermediate Representation) library, providing analytical continuation and sparse representation functionality for quantum many-body physics calculations.

Features

  • Intermediate Representation (IR) basis for fermionic and bosonic statistics
  • Independent Discrete Lehmann Representation (DLR) basis for fermionic and bosonic statistics
  • ESPRIT and MiniPole pole reconstruction
  • Sparse Sampling in imaginary time and Matsubara frequencies

Documentation

The Rust User Guide provides browser-readable tutorials with figures, including MiniPole contour selection. The guide and current API reference follow main (Rust 1.96+). For AI-assisted Rust use, load the SparseIR Rust usage skill when choosing crates, imports, or numerical conventions. Follow the guide's Git installation instructions to run its examples; the crates.io release API may differ.

Installation

As a Rust Library

Add to your Cargo.toml:

[dependencies]
sparse-ir = "0.11.0"

Optional: System BLAS Support

By default, sparse-ir uses Faer (pure Rust) for matrix operations in fit and evaluate routines. To use system BLAS instead (e.g., OpenBLAS, Intel MKL) for better performance, enable the system-blas feature:

[dependencies]
sparse-ir = { version = "0.11.0", features = ["system-blas"] }

Note: When system-blas is enabled, fit and evaluate operations will use BLAS. When not linked, Faer is used as the fallback.

Usage

Basic Example

use sparse_ir::*;

fn main() -> Result<(), sparse_ir::Error> {
    // Create a finite temperature basis
    let beta = 10.0;
    let lambda = 10.0; // beta * omega_max
    let kernel = LogisticKernel::new(lambda)?;
    let basis = FermionicBasis::new(kernel, beta, None, None)?;

    // Generate sampling points
    let sampling = TauSampling::new(&basis)?;

    // Use the basis for calculations
    let tau_points = sampling.sampling_points();
    println!("Generated {} sampling points", tau_points.len());
    Ok(())
}

SVE Example

use sparse_ir::*;

fn main() -> Result<(), sparse_ir::Error> {
    // Create a kernel for analytical continuation
    let kernel = LogisticKernel::new(1.0)?;

    // Compute the SVE to an accuracy of 1e-12, keeping at most 100 singular values
    let sve_result = compute_sve(kernel, Some(1e-12), None, Some(100), TworkType::Auto)?;

    println!("SVE computed with {} singular values", sve_result.s().len());
    Ok(())
}

API Documentation

The released API documentation is available at docs.rs/sparse-ir. For the current main API, use the guide's API reference.

Performance

This implementation is optimized for high performance:

  • Pure Rust: No external C/C++ dependencies for core functionality
  • SIMD Optimized: Uses Faer for matrix-matrix products (evaluate and fit routines). Optionally, system BLAS can be used for these operations for better performance.

Dependencies

License

This crate is dual-licensed under the terms of the MIT license and the Apache License (Version 2.0).

Third-Party Licenses

The col_piv_qr module is based on code from the nalgebra library, which is licensed under the Apache License 2.0:

  • nalgebra: Apache License 2.0
    • Original source: nalgebra/src/linalg/col_piv_qr.rs
    • Copyright 2020 Sébastien Crozet
    • See Apache License 2.0 for details

Modifications and additions to the nalgebra code (including early termination support) are available under the same dual license as this crate (MIT OR Apache-2.0).

Contributing

Contributions are welcome! Please see our development guide for details.

References

  • sparse-ir: optimal compression and sparse sampling of many-body propagators
    Markus Wallerberger, Samuel Badr, Shintaro Hoshino, Fumiya Kakizawa, Takashi Koretsune, Yuki Nagai, Kosuke Nogaki, Takuya Nomoto, Hitoshi Mori, Junya Otsuki, Soshun Ozaki, Rihito Sakurai, Constanze Vogel, Niklas Witt, Kazuyoshi Yoshimi, Hiroshi Shinaoka
    arXiv:2206.11762 | SoftwareX 21, 101266 (2023)
  • Python wrapper: sparse-ir
  • Julia wrapper: SparseIR.jl