sparse-ir
IR basis, DLR, ESPRIT/MiniPole and sparse sampling for imaginary-time Green's functions, in pure Rust.
Features
All of these are in the current release on crates.io:
- Intermediate representation (IR) basis for fermionic and bosonic statistics
- Discrete Lehmann representation (DLR), built independently of an IR basis
(
DiscreteLehmannRepresentation::new,DlrBuilder) or from one (from_ir) - ESPRIT and MiniPole pole reconstruction (
sparse_ir::esprit,sparse_ir::minipole) - Sparse sampling in imaginary time and Matsubara frequencies
Documentation
The Rust User Guide has
tutorials with figures and runnable examples, written against the current
release; start with its
installation
and conventions
pages. The API reference for the release is on
docs.rs/sparse-ir; the guide also hosts the
API reference built from main.
For AI-assisted Rust use, load the SparseIR Rust usage
skill
when choosing crates, imports, or numerical conventions.
Installation
sparse-ir requires Rust 1.96 or newer. Add it to your Cargo.toml:
[]
= "0.16.0"
Optional: system BLAS
By default, sparse-ir uses faer (pure Rust)
for the matrix products in fit and evaluate. To route them through the
LP64 BLAS installed on your system (e.g. OpenBLAS, Intel MKL), enable the
system-blas feature:
[]
= { = "0.16.0", = ["system-blas"] }
Both backends implement the same transforms and memory-order contract; the feature only changes which implementation multiplies the matrices. The results are not guaranteed to be bit-identical: rounding can differ, and an ill-conditioned step such as the DLR coefficient transforms can amplify the difference (about 1e-12 was measured, SpM-lab/sparse-ir-rs#326).
Usage
Matsubara frequencies are indexed by the reduced integer n, with
iν_n = i n π/β (n odd for fermions, even for bosons). Imaginary-time
sampling points lie in [−β/2, β/2]. See the guide's
conventions
page for details.
Quick start: fit and evaluate with the IR basis
Build an IR basis, sample a Green's function G(τ) on the basis's τ points, fit its IR coefficients g_l, and evaluate them on the Matsubara sampling points. The model is a single pole at ω = 0.5, whose exact values are known on both axes.
use ;
DLR without an IR basis
The DLR represents G as a sum of poles ω_p with coefficients c_p.
DiscreteLehmannRepresentation::new(beta, wmax, eps) chooses the poles
directly, without building an IR basis, and works with the same sampling
types.
use ;
More examples, including IR ↔ DLR transforms, MiniPole and applied calculations, are in the user guide.
Crate layout
sparse-ir re-exports the crates it is made of, under their usual paths; you
can also depend on them directly:
sparse-ir-sve: the singular value expansion of integral kernels, with the ACA-accelerated truncated SVD;sparse-ir-core: statistics, errors, GEMM, fitters, theBasistrait and sparse sampling;sparse-ir-basis: the kernels and the IR basisFiniteTempBasis;sparse-ir-dlr: the discrete Lehmann representation;sparse-ir-minipole: ESPRIT and minimal pole representations.
Dependencies
- Tensors and linear algebra: tenferro-rs (CPU) + faer
- Extended precision: xprec-rs
License
This crate is dual-licensed under the terms of the MIT license and the Apache License (Version 2.0).
- You may use this crate under the terms of either license, at your option:
Third-party licenses
The col_piv_qr module of sparse-ir-sve 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
- Original source:
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); see sparse-ir-sve/LICENSE-THIRD-PARTY.
The ESPRIT and MiniPole code of sparse-ir-minipole is a port of
MiniPole (MIT License); see
sparse-ir-minipole/LICENSE-THIRD-PARTY.
Contributing
Contributions are welcome! Please see the 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