Skip to main content

sparse_ir/
lib.rs

1//! # sparse-ir: Rust implementation of SparseIR functionality
2//!
3//! A high-performance implementation of the SparseIR (Sparse Intermediate Representation)
4//! library in Rust, providing analytical continuation and sparse representation
5//! functionality for quantum many-body physics calculations.
6
7/// Print a warning to stderr only when the `SPARSEIR_DEBUG` environment
8/// variable enables debug diagnostics (see [`is_debug_enabled`] for the
9/// accepted values).
10///
11/// Library code must not write to stderr unconditionally; these are advisory
12/// diagnostics (e.g. ill-conditioned sampling) for debugging, not error reports.
13#[macro_export]
14macro_rules! debug_warn {
15    ($($arg:tt)*) => {
16        if $crate::is_debug_enabled() {
17            eprintln!("[SPARSEIR WARN] {}", format!($($arg)*));
18        }
19    };
20}
21
22pub mod basis;
23pub mod basis_trait; // Common trait for basis representations
24pub(crate) mod col_piv_qr; // Column-pivoted QR decomposition using nalgebra
25mod debug; // SPARSEIR_DEBUG switch for debug diagnostics
26pub mod dlr; // Discrete Lehmann Representation utilities
27pub mod error; // Error type of the public API
28pub mod fitters; // Least-squares fitters (real/complex matrices)
29pub mod fpu_check; // FPU state checking for Intel Fortran compatibility
30pub mod freq;
31pub mod gauss;
32pub mod gemm; // Matrix multiplication utilities (Faer backend)
33pub(crate) mod interpolation1d;
34pub mod kernel;
35pub mod kernelmatrix;
36pub mod matsubara_sampling; // Sparse sampling in Matsubara frequencies
37pub mod numeric;
38pub mod poly;
39pub mod polyfourier;
40pub mod sampling; // Sparse sampling in imaginary time
41pub mod special_functions;
42pub mod sve;
43pub mod taufuncs;
44pub mod traits;
45pub mod tsvd; // High-precision truncated SVD using nalgebra // Imaginary time τ normalization utilities
46
47// Re-export commonly used types and traits
48pub use basis::{BosonicBasis, FermionicBasis, FiniteTempBasis};
49pub use basis_trait::Basis;
50pub use debug::is_debug_enabled;
51pub use dlr::{
52    DiscreteLehmannRepresentation, bosonic_single_pole, fermionic_single_pole, giwn_single_pole,
53    gtau_single_pole,
54};
55pub use error::{ArrayRole, Error, ErrorKind};
56pub use fitters::InplaceFitter;
57pub use freq::{BosonicFreq, FermionicFreq, MatsubaraFreq};
58pub use gauss::{Rule, legendre, legendre_custom, legendre_twofloat};
59pub use kernel::{
60    AbstractKernel, CentrosymmKernel, KernelProperties, LogisticKernel, LogisticSVEHints,
61    RegularizedBoseKernel, RegularizedBoseSVEHints, SVEHints, SymmetryType,
62    compute_logistic_kernel,
63};
64pub use kernelmatrix::{
65    DiscretizedKernel, matrix_from_gauss, matrix_from_gauss_noncentrosymmetric,
66    matrix_from_gauss_with_segments,
67};
68pub use matsubara_sampling::{MatsubaraSampling, MatsubaraSamplingPositiveOnly};
69pub use numeric::CustomNumeric;
70pub use poly::{PiecewiseLegendrePoly, PiecewiseLegendrePolyVector};
71pub use polyfourier::{
72    BosonicPiecewiseLegendreFT, BosonicPiecewiseLegendreFTVector, FermionicPiecewiseLegendreFT,
73    FermionicPiecewiseLegendreFTVector, PiecewiseLegendreFT, PiecewiseLegendreFTVector, PowerModel,
74};
75pub use sampling::TauSampling;
76pub use sve::{
77    CentrosymmSVE, SVDStrategy, SVEResult, SVEStrategy, SamplingSVE, TworkType, compute_sve,
78};
79pub use traits::{Bosonic, Fermionic, Statistics, StatisticsMarker, StatisticsType};
80pub use tsvd::{
81    SVDResult, TSVDConfig, svd_decompose, tsvd, tsvd_df64, tsvd_df64_from_f64, tsvd_f64,
82};
83
84// Re-export external dependencies for convenience
85pub use mdarray::{DTensor, DynRank, Tensor};
86pub use xprec::Df64;
87
88// Test utilities (only available in test mode)
89#[cfg(test)]
90pub mod test_utils;