Skip to content

Commit 1bf49bd

Browse files
authored
feat: reintroduce iscentrosymmetric function from v1.x.x (#94)
- Add default iscentrosymmetric(::AbstractKernel) = false with docstring - Specialize for LogisticKernel and RegularizedBoseKernel to return true - Export iscentrosymmetric function - Add unit tests for iscentrosymmetric
1 parent e3b71a1 commit 1bf49bd

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/SparseIR.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export FiniteTempBasis, FiniteTempBasisSet
1313
export DiscreteLehmannRepresentation
1414
export overlap
1515
export LogisticKernel, RegularizedBoseKernel
16+
export iscentrosymmetric
1617
export AugmentedBasis, TauConst, TauLinear, MatsubaraConst
1718
export TauSampling, MatsubaraSampling, evaluate, fit, evaluate!, fit!,
1819
sampling_points, npoints

src/abstract.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ iswellconditioned(::AbstractBasis) = true
197197

198198
###############################################################################
199199

200+
"""
201+
iscentrosymmetric(kernel::AbstractKernel)
202+
203+
Return whether the kernel satisfies `K(x, y) == K(-x, -y)` for all values of x and y.
204+
Defaults to `false`.
205+
206+
A centrosymmetric kernel can be block-diagonalized, speeding up the singular value
207+
expansion by a factor of 4.
208+
"""
209+
iscentrosymmetric(::AbstractKernel) = false
210+
200211
Base.broadcastable(kernel::AbstractKernel) = Ref(kernel)
201212

202213
Base.broadcastable(sampling::AbstractSampling) = Ref(sampling)

src/kernel.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ end
6767

6868
Λ(kernel::LogisticKernel) = kernel.Λ
6969
Λ(kernel::RegularizedBoseKernel) = kernel.Λ
70+
71+
iscentrosymmetric(::LogisticKernel) = true
72+
iscentrosymmetric(::RegularizedBoseKernel) = true

test/spir/kernel_tests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
lam = 42
66
kernel = LogisticKernel(lam)
77
@test SparseIR.Λ(kernel) == lam
8+
@test iscentrosymmetric(kernel)
89
end
910

1011
@testset "Regularized Bose kernel" begin
1112
lam = 42
1213
kernel = RegularizedBoseKernel(lam)
1314
@test SparseIR.Λ(kernel) == lam
15+
@test iscentrosymmetric(kernel)
1416
end
1517
end

0 commit comments

Comments
 (0)