Skip to content

Commit f27117c

Browse files
Log kernel point evaluation for weighted ChebyshevU (#68)
* Fix bug in colsupport for Hilbert * add comments * add comments * Fix within interval stieltjes evaluation * Use ChebyshevT * Update test_stieltjes.jl * Log kernel real point evalulation * Notation and Sheehan's fix for complex type Co-authored-by: Sheehan Olver <[email protected]>
1 parent ef991f8 commit f27117c

File tree

3 files changed

+62
-16
lines changed

3 files changed

+62
-16
lines changed

src/stieltjes.jl

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ associated(::ChebyshevU{T}) where T = ChebyshevU{T}()
5858

5959

6060
const StieltjesPoint{T,W<:Number,V,D} = BroadcastQuasiMatrix{T,typeof(inv),Tuple{BroadcastQuasiMatrix{T,typeof(-),Tuple{W,QuasiAdjoint{V,Inclusion{V,D}}}}}}
61+
const LogKernelPoint{T<:Real,C,W<:Number,V,D} = BroadcastQuasiMatrix{T,typeof(log),Tuple{BroadcastQuasiMatrix{T,typeof(abs),Tuple{BroadcastQuasiMatrix{C,typeof(-),Tuple{W,QuasiAdjoint{V,Inclusion{V,D}}}}}}}}
6162
const ConvKernel{T,D1,D2} = BroadcastQuasiMatrix{T,typeof(-),Tuple{D1,QuasiAdjoint{T,D2}}}
6263
const Hilbert{T,D1,D2} = BroadcastQuasiMatrix{T,typeof(inv),Tuple{ConvKernel{T,Inclusion{T,D1},Inclusion{T,D2}}}}
6364
const LogKernel{T,D1,D2} = BroadcastQuasiMatrix{T,typeof(log),Tuple{BroadcastQuasiMatrix{T,typeof(abs),Tuple{ConvKernel{T,Inclusion{T,D1},Inclusion{T,D2}}}}}}
@@ -79,18 +80,18 @@ end
7980
log.(x .+ one(T)) .- log.(one(T) .- x)
8081
end
8182

82-
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wT::Weighted{<:Any,<:ChebyshevT})
83+
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wT::Weighted{<:Any,<:ChebyshevT})
8384
T = promote_type(eltype(H), eltype(wT))
8485
ChebyshevU{T}() * _BandedMatrix(Fill(-convert(T,π),1,∞), ℵ₀, -1, 1)
8586
end
8687

87-
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wU::Weighted{<:Any,<:ChebyshevU})
88+
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wU::Weighted{<:Any,<:ChebyshevU})
8889
T = promote_type(eltype(H), eltype(wU))
8990
ChebyshevT{T}() * _BandedMatrix(Fill(convert(T,π),1,∞), ℵ₀, 1, -1)
9091
end
9192

9293

93-
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wP::Weighted{<:Any,<:OrthogonalPolynomial})
94+
@simplify function *(H::Hilbert{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wP::Weighted{<:Any,<:OrthogonalPolynomial})
9495
P = wP.P
9596
w = orthogonalityweight(P)
9697
A = recurrencecoefficients(P)[1]
@@ -150,11 +151,11 @@ end
150151
PiecewiseInterlace(c,d) * BlockBroadcastArray{promote_type(eltype(H),eltype(S))}(hvcat, 2, A, B, C, D)
151152
end
152153

153-
###
154+
###
154155
# LogKernel
155156
###
156157

157-
@simplify function *(L::LogKernel{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wT::Weighted{<:Any,<:ChebyshevT})
158+
@simplify function *(L::LogKernel{<:Any,<:ChebyshevInterval,<:ChebyshevInterval}, wT::Weighted{<:Any,<:ChebyshevT})
158159
T = promote_type(eltype(L), eltype(wT))
159160
ChebyshevT{T}() * Diagonal(Vcat(-convert(T,π)*log(2*one(T)),-convert(T,π)./(1:∞)))
160161
end
@@ -172,11 +173,11 @@ end
172173

173174

174175

175-
###
176+
###
176177
# PowKernel
177178
###
178179

179-
@simplify function *(K::PowKernel, wT::Weighted{<:Any,<:Jacobi})
180+
@simplify function *(K::PowKernel, wT::Weighted{<:Any,<:Jacobi})
180181
T = promote_type(eltype(K), eltype(wT))
181182
cnv,α = K.args
182183
x,y = K.args[1].args[1].args
@@ -219,6 +220,29 @@ sqrtx2(x::Real) = sign(x)*sqrt(x^2-1)
219220
transpose(convert(T,π) * ξ.^oneto(∞))
220221
end
221222

223+
####
224+
# LogKernelPoint
225+
####
226+
227+
@simplify function *(L::LogKernelPoint, wP::Weighted{<:Any,<:ChebyshevU})
228+
T = promote_type(eltype(L), eltype(wP))
229+
z, xc = parent(L).args[1].args[1].args
230+
if z in axes(wP,1)
231+
Tn = Vcat(convert(T,π)*log(2*one(T)), convert(T,π)*ChebyshevT()[z,2:end]./oneto(∞))
232+
return transpose((Tn[3:end]-Tn[1:end])/2)
233+
else
234+
# for U_k where k>=1
235+
ξ = inv(z + sqrtx2(z))
236+
ζ = (convert(T,π)*ξ.^oneto(∞))./oneto(∞)
237+
ζ = (ζ[3:end]- ζ[1:end])/2
238+
239+
# for U_0
240+
ζ = Vcat(convert(T,π)*^2/4 - (log.(abs.(ξ)) + log(2*one(T)))/2), ζ)
241+
return transpose(ζ)
242+
end
243+
244+
end
245+
222246
"""
223247
HilbertVandermonde(M, data)
224248
@@ -244,7 +268,7 @@ function cache_filldata!(H::HilbertVandermonde{T}, kr, jr) where T
244268
n,m = H.datasize
245269
isempty(jr) && return
246270
resize!(H.colsupport, max(length(H.colsupport), maximum(jr)))
247-
271+
248272
isempty(kr) || (H.data[(n+1):maximum(kr),1:m] .= zero(T))
249273
for j in (m+1):maximum(jr)
250274
u = H.M * [H.data[:,j-1]; Zeros{T}(∞)]
@@ -258,7 +282,7 @@ end
258282
= chebyshevt(x)
259283
ψ_1 =\ inv.(x .+ sqrtx2.(x)) # same ψ_1 = x .- sqrt(x^2 - 1) but with relative accuracy as x -> ∞
260284
data = convert(eltype(H),π) * Matrix(reshape(paddeddata(ψ_1),:,1))
261-
# Operator has columns π * ψ_1^k
285+
# Operator has columns π * ψ_1^k
262286
* HilbertVandermonde(Clenshaw(T̃ * ψ_1, T̃), data)
263287
end
264288

@@ -273,14 +297,14 @@ end
273297
(inv.(z̃ .-') * P)[:,parentindices(wT)[2]]
274298
end
275299

276-
@simplify function *(H::Hilbert, wT::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:AbstractAffineQuasiVector,<:Any}})
300+
@simplify function *(H::Hilbert, wT::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:AbstractAffineQuasiVector,<:Any}})
277301
P = parent(wT)
278302
x = axes(P,1)
279303
apply(*, inv.(x .- x'), P)[parentindices(wT)...]
280304
end
281305

282306

283-
@simplify function *(L::LogKernel, wT::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:AbstractAffineQuasiVector,<:Slice}})
307+
@simplify function *(L::LogKernel, wT::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:AbstractAffineQuasiVector,<:Slice}})
284308
V = promote_type(eltype(L), eltype(wT))
285309
wP = parent(wT)
286310
kr, jr = parentindices(wT)
@@ -295,7 +319,7 @@ end
295319

296320
### generic fallback
297321
for Op in (:Hilbert, :StieltjesPoint, :LogKernel, :PowKernel)
298-
@eval @simplify function *(H::$Op, wP::WeightedBasis{<:Any,<:Weight,<:Any})
322+
@eval @simplify function *(H::$Op, wP::WeightedBasis{<:Any,<:Weight,<:Any})
299323
w,P = wP.args
300324
Q = OrthogonalPolynomial(w)
301325
(H * Weighted(Q)) * (Q \ P)
@@ -497,4 +521,4 @@ function dot(v::AbstractVector{T}, W::PowerLawMatrix, q::AbstractVector{T}) wher
497521
vpad, qpad = paddeddata(v), paddeddata(q)
498522
vl, ql = length(vpad), length(qpad)
499523
return dot(vpad,W[1:vl,1:ql]*qpad)
500-
end
524+
end

test/test_interlace.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import ClassicalOrthogonalPolynomials: PiecewiseInterlace
6464
= H̃[Block.(1:N), Block.(1:N)] \ Vp_cfs_N;
6565
c1,c2 = cμ[Block(1)]
6666
μ = W[:,Block.(1:N-1)] * cμ[Block.(2:N)]/2;
67-
67+
6868
# H * μ == Vp(x) + c1 on first interval
6969
# H * μ == Vp(x) + c2 on second interval
7070
end

test/test_stieltjes.jl

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

55
@testset "Associated" begin
@@ -43,6 +43,28 @@ end
4343
@test (H*w_P)[0.1] (log(1+(-0.8)) - log(1-(-0.8)))
4444
end
4545

46+
@testset "LogKernelPoint" begin
47+
wU = Weighted(ChebyshevU())
48+
x = axes(wU,1)
49+
z = 0.1+0.2im
50+
L = log.(abs.(z.-x'))
51+
@test L isa LogKernelPoint{Float64,ComplexF64,ComplexF64,Float64,ChebyshevInterval{Float64}}
52+
53+
@testset "Real point" begin
54+
U = ChebyshevU()
55+
x = axes(U,1)
56+
57+
t = 2.0
58+
@test (log.(abs.(t .- x') )* Weighted(U))[1,1:3] [1.0362686329607178,-0.4108206734393296, -0.054364775221816465] #mathematica
59+
60+
t = 0.5
61+
@test (log.(abs.(t .- x') )* Weighted(U))[1,1:3] [-1.4814921268505252, -1.308996938995747, 0.19634954084936207] #mathematica
62+
63+
t = 0.5+0im
64+
@test (log.(abs.(t .- x') )* Weighted(U))[1,1:3] [-1.4814921268505252, -1.308996938995747, 0.19634954084936207] #mathematica
65+
end
66+
end
67+
4668
@testset "Stieltjes" begin
4769
T = Chebyshev()
4870
wT = ChebyshevWeight() .* T
@@ -364,4 +386,4 @@ end
364386
@time ClassicalOrthogonalPolynomials.resizedata!(D,100);
365387
end
366388
end
367-
end
389+
end

0 commit comments

Comments
 (0)