pub fn normalize_tau<S: StatisticsType>(
tau: f64,
beta: f64,
) -> Result<(f64, f64), Error>Expand description
Normalize τ to the range [0, β] with statistics-dependent boundary conditions
Handles boundary conditions based on statistics:
- Fermions: Anti-periodic G(τ + β) = -G(τ)
- Bosons: Periodic G(τ + β) = G(τ)
§Type Parameters
S- Statistics type (Fermionic or Bosonic)
§Arguments
tau- Imaginary time in range [-β, β]beta- Inverse temperature
§Returns
(tau_normalized, sign)- Normalized τ ∈ [0, β] and sign factor
§Errors
Error::InvalidParameterifbetais not positive and finiteError::OutOfDomainiftauis outside [-β, β] or NaN
§Boundary Interpretation
βis interpreted asβ-(left limit at β):tau == betastays in normal range-βis read as (-β)⁺: it wraps to 0, with a sign flip for fermions-0.0(negative zero) is treated as being in the odd period for fermions
§Special Cases
For Fermionic statistics:
tau = -0.0(negative zero) →(tau_normalized = β, sign = -1.0)tau = 0.0(positive zero) →(tau_normalized = 0.0, sign = 1.0)tau ∈ [-β, 0)→ wraps to [0, β] withsign = -1.0
For Bosonic statistics:
tau = -0.0(negative zero) →(tau_normalized = β, sign = 1.0)(periodic)tau = 0.0(positive zero) →(tau_normalized = 0.0, sign = 1.0)tau ∈ [-β, 0)→ wraps to [0, β] withsign = 1.0
§Examples
use sparse_ir::taufuncs::normalize_tau;
use sparse_ir::traits::{Bosonic, Fermionic};
// Normal negative value
let (tau_norm, sign) = normalize_tau::<Fermionic>(-0.3, 1.0).unwrap();
assert!((tau_norm - 0.7).abs() < 1e-14);
assert_eq!(sign, -1.0);
// Negative zero
let (tau_norm, sign) = normalize_tau::<Fermionic>(-0.0, 1.0).unwrap();
assert!((tau_norm - 1.0).abs() < 1e-14);
assert_eq!(sign, -1.0);
// -β wraps to 0 (with a sign flip for fermions only)
assert_eq!(normalize_tau::<Fermionic>(-1.0, 1.0).unwrap(), (0.0, -1.0));
assert_eq!(normalize_tau::<Bosonic>(-1.0, 1.0).unwrap(), (0.0, 1.0));
// τ outside [-β, β] is an error
assert!(normalize_tau::<Fermionic>(1.5, 1.0).is_err());