Summary
The Matsubara sampling point calculation (default_matsubara_sampling_points and related methods) relies on the assumption that basis functions in Matsubara space are either pure imaginary or pure real, which is only guaranteed for centrosymmetric kernels.
For non-centrosymmetric kernels, these methods would produce incorrect results silently or panic at runtime.
Current behavior
FiniteTempBasis::default_matsubara_sampling_points() panics at runtime with a message about centrosymmetry (basis.rs:446-451)
FiniteTempBasis::default_tau_sampling_points() also panics (basis.rs:335-340)
MatsubaraSamplingPositiveOnly uses ComplexToRealFitter which assumes real coefficients — this is only valid when basis functions have definite parity (centrosymmetric case)
While FiniteTempBasis<K, S> requires K: CentrosymmKernel at the type level, the Basis<S> trait itself does not encode this constraint. Any future Basis implementation for a non-centrosymmetric kernel could reach these code paths.
Desired behavior
Return explicit errors (e.g., Result types or at minimum clear error messages) rather than relying on:
- Runtime panics that may not clearly indicate the root cause
- Silent incorrect results from
MatsubaraSamplingPositiveOnly when coefficients are not real
Root cause
The Matsubara sampling algorithm uses sign_changes / find_extrema of uhat basis functions, which assumes each uhat_l(iωn) is either pure real or pure imaginary (a consequence of centrosymmetry). For non-centrosymmetric kernels, uhat_l are general complex-valued and these algorithms do not apply.
Affected code
sparse-ir/src/basis.rs: default_matsubara_sampling_points, default_tau_sampling_points, default_matsubara_sampling_points_impl
sparse-ir/src/matsubara_sampling.rs: MatsubaraSamplingPositiveOnly::new(), ::with_sampling_points()
sparse-ir/src/polyfourier.rs: sign_changes, find_extrema
Summary
The Matsubara sampling point calculation (
default_matsubara_sampling_pointsand related methods) relies on the assumption that basis functions in Matsubara space are either pure imaginary or pure real, which is only guaranteed for centrosymmetric kernels.For non-centrosymmetric kernels, these methods would produce incorrect results silently or panic at runtime.
Current behavior
FiniteTempBasis::default_matsubara_sampling_points()panics at runtime with a message about centrosymmetry (basis.rs:446-451)FiniteTempBasis::default_tau_sampling_points()also panics (basis.rs:335-340)MatsubaraSamplingPositiveOnlyusesComplexToRealFitterwhich assumes real coefficients — this is only valid when basis functions have definite parity (centrosymmetric case)While
FiniteTempBasis<K, S>requiresK: CentrosymmKernelat the type level, theBasis<S>trait itself does not encode this constraint. Any futureBasisimplementation for a non-centrosymmetric kernel could reach these code paths.Desired behavior
Return explicit errors (e.g.,
Resulttypes or at minimum clear error messages) rather than relying on:MatsubaraSamplingPositiveOnlywhen coefficients are not realRoot cause
The Matsubara sampling algorithm uses
sign_changes/find_extremaofuhatbasis functions, which assumes eachuhat_l(iωn)is either pure real or pure imaginary (a consequence of centrosymmetry). For non-centrosymmetric kernels,uhat_lare general complex-valued and these algorithms do not apply.Affected code
sparse-ir/src/basis.rs:default_matsubara_sampling_points,default_tau_sampling_points,default_matsubara_sampling_points_implsparse-ir/src/matsubara_sampling.rs:MatsubaraSamplingPositiveOnly::new(),::with_sampling_points()sparse-ir/src/polyfourier.rs:sign_changes,find_extrema