diff --git a/Project.toml b/Project.toml index 7eb7b5c..67d5609 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SparseIR" uuid = "4fe2279e-80f0-4adb-8463-ee114ff56b7d" authors = ["Samuel Badr ", "Hiroshi Shinaoka ", "Markus Wallerberger "] -version = "1.0.19" +version = "1.1.0" [deps] Bessels = "0e736298-9ec6-45e8-9647-e4fc86a2fe38" diff --git a/src/abstract.jl b/src/abstract.jl index 8d73f41..50f0f22 100644 --- a/src/abstract.jl +++ b/src/abstract.jl @@ -176,6 +176,13 @@ Return sampling points. """ sampling_points(sampling::AbstractSampling) = sampling.sampling_points +""" + basis(sampling::AbstractSampling) + +Return the IR basis associated with `sampling`. +""" +basis(sampling::AbstractSampling) = sampling.basis + function Base.show(io::IO, ::MIME"text/plain", smpl::S) where {S<:AbstractSampling} println(io, "$S with sampling points:") for p in sampling_points(smpl)[begin:(end - 1)] diff --git a/src/sampling.jl b/src/sampling.jl index a3237ad..17d9daf 100644 --- a/src/sampling.jl +++ b/src/sampling.jl @@ -6,10 +6,11 @@ Sparse sampling in imaginary time. Allows the transformation between the IR basis and a set of sampling points in (scaled/unscaled) imaginary time. """ -struct TauSampling{T,TMAT,F} <: AbstractSampling{T,TMAT,F} +struct TauSampling{T,TMAT,F,B} <: AbstractSampling{T,TMAT,F} sampling_points :: Vector{T} matrix :: Matrix{TMAT} matrix_svd :: F + basis :: B end """ @@ -24,7 +25,7 @@ function TauSampling(basis::AbstractBasis; sampling_points=default_tau_sampling_points(basis), factorize=true) matrix = eval_matrix(TauSampling, basis, sampling_points) matrix_svd = factorize ? svd(matrix) : nothing - sampling = TauSampling(sampling_points, matrix, matrix_svd) + sampling = TauSampling(sampling_points, matrix, matrix_svd, basis) if factorize && iswellconditioned(basis) && cond(sampling) > 1e8 @warn "Sampling matrix is poorly conditioned (cond = $(cond(sampling)))." end @@ -41,11 +42,13 @@ Sparse sampling in Matsubara frequencies. Allows the transformation between the IR basis and a set of sampling points in (scaled/unscaled) imaginary frequencies. """ -struct MatsubaraSampling{T<:MatsubaraFreq,TMAT,F} <: AbstractSampling{T,TMAT,F} +struct MatsubaraSampling{T<:MatsubaraFreq,TMAT,F,B<:AbstractBasis} <: + AbstractSampling{T,TMAT,F} sampling_points :: Vector{T} matrix :: Matrix{TMAT} matrix_svd :: F positive_only :: Bool + basis :: B end """ @@ -82,7 +85,7 @@ function MatsubaraSampling(basis::AbstractBasis; positive_only=false, else svd_matrix = nothing end - sampling = MatsubaraSampling(sampling_points, matrix, svd_matrix, positive_only) + sampling = MatsubaraSampling(sampling_points, matrix, svd_matrix, positive_only, basis) if factorize && iswellconditioned(basis) && cond(sampling) > 1e8 @warn "Sampling matrix is poorly conditioned (cond = $(cond(sampling)))." end diff --git a/test/sampling.jl b/test/sampling.jl index 2dcb9d5..d792e36 100644 --- a/test/sampling.jl +++ b/test/sampling.jl @@ -76,6 +76,7 @@ isdefined(Main, :sve_logistic) || include("_conftest.jl") basis = FiniteTempBasis(stat, 1, Λ; sve_result=sve_logistic[Λ]) smpl = TauSampling(basis) + @test basis === SparseIR.basis(smpl) @test issorted(smpl.sampling_points) Random.seed!(5318008) @@ -109,6 +110,7 @@ isdefined(Main, :sve_logistic) || include("_conftest.jl") basis = FiniteTempBasis(stat, 1, Λ; sve_result=sve_logistic[Λ]) smpl = MatsubaraSampling(basis; positive_only) + @test basis === SparseIR.basis(smpl) if !positive_only @test smpl isa (stat == Fermionic() ? MatsubaraSampling64F : MatsubaraSampling64B)