Skip to content

Commit f2385c7

Browse files
authored
mapped Hilbert transform (#58)
* mapped Hilbert transform * Mapped log kernel * Update test_stieltjes.jl
1 parent b8ccb00 commit f2385c7

File tree

3 files changed

+84
-19
lines changed

3 files changed

+84
-19
lines changed

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ end
323323

324324

325325
function factorize(L::SubQuasiArray{T,2,<:OrthogonalPolynomial,<:Tuple{Inclusion,OneTo}}) where T
326-
x,w = golubwelsch(L)
327326
Q = Normalized(parent(L))[parentindices(L)...]
328327
D = L \ Q
329328
F = factorize(Q)

src/stieltjes.jl

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ end
7171

7272
@simplify function *(H::Hilbert, w::ChebyshevUWeight)
7373
T = promote_type(eltype(H), eltype(w))
74-
fill(convert(T,π), axes(w,1))
74+
convert(T,π) * axes(w,1)
7575
end
7676

7777
@simplify function *(H::Hilbert, w::LegendreWeight)
7878
T = promote_type(eltype(H), eltype(w))
7979
x = axes(w,1)
80-
log.(x .+ 1) .- log.(1 .- x)
80+
log.(x .+ one(T)) .- log.(one(T) .- x)
8181
end
8282

8383
@simplify function *(H::Hilbert, wT::Weighted{<:Any,<:ChebyshevT})
@@ -95,18 +95,48 @@ end
9595
P = wP.P
9696
w = orthogonalityweight(P)
9797
A = recurrencecoefficients(P)[1]
98-
(-A[1]*sum(w))*[zero(axes(P,1)) associated(P)] + (H*w) .* P
98+
Q = associated(P)
99+
(-A[1]*sum(w))*[zero(axes(P,1)) Q] + (H*w) .* P
99100
end
100101

101102
@simplify *(H::Hilbert, P::Legendre) = H * Weighted(P)
102103

104+
105+
106+
@simplify function *(H::Hilbert, w::SubQuasiArray{<:Any,1})
107+
T = promote_type(eltype(H), eltype(w))
108+
m = parentindices(w)[1]
109+
P = parent(w)
110+
x = axes(P,1)
111+
(inv.(x .- x') * P)[m]
112+
end
113+
114+
@simplify function *(H::Hilbert, wP::Weighted{<:Any,<:SubQuasiArray{<:Any,2}})
115+
T = promote_type(eltype(H), eltype(wP))
116+
kr,jr = parentindices(wP.P)
117+
P = parent(wP.P)
118+
x = axes(P,1)
119+
(inv.(x .- x') * Weighted(P))[kr,jr]
120+
end
121+
122+
103123
###
104124
# LogKernel
105125
###
106126

107127
@simplify function *(L::LogKernel, wT::Weighted{<:Any,<:ChebyshevT})
108128
T = promote_type(eltype(L), eltype(wT))
109-
ChebyshevT{T}() * Diagonal(Vcat(-π*log(2*one(T)),-convert(T,π)./(1:∞)))
129+
ChebyshevT{T}() * Diagonal(Vcat(-convert(T,π)*log(2*one(T)),-convert(T,π)./(1:∞)))
130+
end
131+
132+
@simplify function *(H::LogKernel, wT::Weighted{<:Any,<:SubQuasiArray{<:Any,2,<:ChebyshevT,<:Tuple{AbstractAffineQuasiVector,Slice}}})
133+
V = promote_type(eltype(H), eltype(wT))
134+
kr,jr = parentindices(wT.P)
135+
T = parent(wT.P)
136+
x = axes(T,1)
137+
W = Weighted(T)
138+
A = kr.A
139+
T[kr,:] * Diagonal(Vcat(-convert(V,π)*(log(2*one(V))+log(abs(A)))/A,-convert(V,π)./(A * (1:∞))))
110140
end
111141

112142

test/test_stieltjes.jl

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, Test
1+
using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, BandedMatrices, Test
22
import ClassicalOrthogonalPolynomials: Hilbert, StieltjesPoint, ChebyshevInterval, associated, Associated, orthogonalityweight, Weighted, gennormalizedpower, *, dot, PowerLawMatrix, PowKernelPoint
33
import InfiniteArrays: I
44

@@ -23,6 +23,26 @@ end
2323

2424

2525
@testset "Singular integrals" begin
26+
@testset "weights" begin
27+
w_T = ChebyshevTWeight()
28+
w_U = ChebyshevUWeight()
29+
w_P = LegendreWeight()
30+
x = axes(w_T,1)
31+
H = inv.(x .- x')
32+
@test iszero(H*w_T)
33+
@test (H*w_U)[0.1] π/10
34+
@test (H*w_P)[0.1] log(1.1) - log(1-0.1)
35+
36+
w_T = orthogonalityweight(chebyshevt(0..1))
37+
w_U = orthogonalityweight(chebyshevu(0..1))
38+
w_P = orthogonalityweight(legendre(0..1))
39+
x = axes(w_T,1)
40+
H = inv.(x .- x')
41+
@test iszero(H*w_T)
42+
@test (H*w_U)[0.1] (2*0.1-1)*π
43+
@test (H*w_P)[0.1] (log(1+(-0.8)) - log(1-(-0.8)))
44+
end
45+
2646
@testset "Stieltjes" begin
2747
T = Chebyshev()
2848
wT = ChebyshevWeight() .* T
@@ -36,7 +56,7 @@ end
3656

3757
f = wT * [[1,2,3]; zeros(∞)];
3858
J = T \ (x .* T)
39-
59+
4060
@test π*((z*I-J) \ f.args[2])[1,1] (S*f)[1]
4161
@test π*((z*I-J) \ f.args[2])[1,1] (S*f.args[1]*f.args[2])[1]
4262

@@ -55,7 +75,7 @@ end
5575
x = axes(T,1)
5676
@test inv.(t .- x') * Weighted(T) inv.((t+eps()im) .- x') * Weighted(T)
5777
@test (inv.(t .- x') * Weighted(U))[1:10] (inv.((t+eps()im) .- x') * Weighted(U))[1:10]
58-
78+
5979
t = 0.5
6080
@test_broken inv.(t .- x') * Weighted(T)
6181
@test_broken inv.(t .- x') * Weighted(U)
@@ -71,7 +91,7 @@ end
7191

7292
@testset "weights" begin
7393
@test H * ChebyshevTWeight() QuasiZeros{Float64}((x,))
74-
@test H * ChebyshevUWeight() QuasiFill(1.0π,(x,))
94+
@test H * ChebyshevUWeight() == π*x
7595
@test (H * LegendreWeight())[0.1] log((0.1+1)/(1-0.1))
7696
end
7797

@@ -82,15 +102,16 @@ end
82102
@test (Ultraspherical(1) \ (H*wT) * (wT \ wU))[1:10,1:10] ==
83103
((Ultraspherical(1) \ Chebyshev()) * (Chebyshev() \ (H*wU)))[1:10,1:10]
84104

85-
# Other axes
86-
x = Inclusion(0..1)
87-
y = 2x .- 1
88-
H = inv.(x .- x')
105+
@testset "Other axes" begin
106+
x = Inclusion(0..1)
107+
y = 2x .- 1
108+
H = inv.(x .- x')
89109

90-
wT2 = wT[y,:]
91-
wU2 = wU[y,:]
92-
@test (Ultraspherical(1)[y,:]\(H*wT2))[1:10,1:10] == diagm(1 => fill(-π,9))
93-
@test (Chebyshev()[y,:]\(H*wU2))[1:10,1:10] == diagm(-1 => fill(1.0π,9))
110+
wT2 = wT[y,:]
111+
wU2 = wU[y,:]
112+
@test (Ultraspherical(1)[y,:]\(H*wT2))[1:10,1:10] == diagm(1 => fill(-π,9))
113+
@test (Chebyshev()[y,:]\(H*wU2))[1:10,1:10] == diagm(-1 => fill(1.0π,9))
114+
end
94115

95116
@testset "Legendre" begin
96117
P = Legendre()
@@ -99,6 +120,14 @@ end
99120
X = jacobimatrix(P)
100121
@test Q[0.1,1:11]'*X[1:11,1:10] (0.1 * Array(Q[0.1,1:10])' - [2 zeros(1,9)])
101122
end
123+
124+
@testset "mapped" begin
125+
T = chebyshevt(0..1)
126+
U = chebyshevu(0..1)
127+
x = axes(T,1)
128+
H = inv.(x .- x')
129+
@test U\H*Weighted(T) isa BandedMatrix
130+
end
102131
end
103132

104133
@testset "Log kernel" begin
@@ -122,6 +151,13 @@ end
122151
u = wT * (2 *(T \ exp.(x)))
123152
@test u[0.1] exp(0.1)/sqrt(0.1-0.1^2)
124153
@test (L * u)[0.5] -7.471469928754152 # Mathematica
154+
155+
@testset "mapped" begin
156+
T = chebyshevt(0..1)
157+
x = axes(T,1)
158+
L = log.(abs.(x .- x'))
159+
@test T[0.2,:]'*((T\L*Weighted(T)) * (T\exp.(x))) -2.9976362326874373 # Mathematica
160+
end
125161
end
126162

127163
@testset "pow kernel" begin
@@ -143,7 +179,7 @@ end
143179

144180
u = Weighted(U) * ((H * Weighted(U)) \ imag(c * x))
145181

146-
ε = eps();
182+
ε = eps();
147183
@test (inv.(0.1+ε*im .- x') * u + inv.(0.1-ε*im .- x') * u)/2 imag(c*0.1)
148184
@test real(inv.(0.1+ε*im .- x') * u ) imag(c*0.1)
149185

@@ -284,4 +320,4 @@ end
284320
@time D = ClassicalOrthogonalPolynomials.LanczosData((1.001 .- x).^0.5, P);
285321
@time ClassicalOrthogonalPolynomials.resizedata!(D,100);
286322
end
287-
end
323+
end

0 commit comments

Comments
 (0)