Skip to content

Commit 6ca0f88

Browse files
committed
Orthogonal connection matrix for Ultraspherical
1 parent 9b7a77b commit 6ca0f88

File tree

5 files changed

+57
-30
lines changed

5 files changed

+57
-30
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
44
version = "0.15.1"
55

6-
76
[deps]
87
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
98
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
@@ -22,6 +21,7 @@ IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
2221
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
2322
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
2423
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
24+
MatrixFactorizations = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
2525
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
2626
RecurrenceRelationshipArrays = "b889d2dc-af3c-4820-88a8-238fa91d3518"
2727
RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c"
@@ -51,6 +51,7 @@ InfiniteLinearAlgebra = "0.10"
5151
IntervalSets = "0.7"
5252
LazyArrays = "2.5.1"
5353
LazyBandedMatrices = "0.11"
54+
MatrixFactorizations = "3.1"
5455
MutableArithmetics = "1"
5556
QuasiArrays = "0.12"
5657
RecurrenceRelationshipArrays = "0.1.2"

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import FastGaussQuadrature: jacobimoment
4848
import BlockArrays: blockedrange, _BlockedUnitRange, unblock, _BlockArray, block, blockindex, BlockSlice, blockvec
4949
import BandedMatrices: bandwidths
5050

51+
using MatrixFactorizations: QRPackedQMatrix
52+
5153
export OrthogonalPolynomial, Normalized, LanczosPolynomial,
5254
Hermite, Jacobi, Legendre, Chebyshev, ChebyshevT, ChebyshevU, ChebyshevInterval, Ultraspherical, Fourier, Laurent, Laguerre,
5355
HermiteWeight, JacobiWeight, ChebyshevWeight, ChebyshevGrid, ChebyshevTWeight, ChebyshevUWeight, UltrasphericalWeight, LegendreWeight, LaguerreWeight,

src/classical/jacobi.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ broadcasted(::LazyQuasiArrayStyle{1}, ::typeof(Base.literal_pow), ::Base.RefValu
2828
The quasi-vector representing the Jacobi weight function ``(1-x)^a (1+x)^b`` on ``[-1,1]``. See also [`jacobiweight`](@ref) and [`Jacobi`](@ref).
2929
# Examples
3030
```jldoctest
31-
julia> J=JacobiWeight(1.0,1.0)
31+
julia> w = JacobiWeight(1.0,1.0)
3232
(1-x)^1.0 * (1+x)^1.0 on -1..1
3333
34-
julia> J[0.5]
34+
julia> w[0.5]
3535
0.75
3636
37-
julia> axes(J)
37+
julia> axes(w)
3838
(Inclusion(-1.0 .. 1.0 (Chebyshev)),)
3939
```
4040
"""
@@ -56,13 +56,13 @@ The [`JacobiWeight`](@ref) affine-mapped to interval `d`.
5656
5757
# Examples
5858
```jldoctest
59-
julia> J = jacobiweight(1, 1, 0..1)
59+
julia> w = jacobiweight(1, 1, 0..1)
6060
(1-x)^1 * (1+x)^1 on -1..1 affine mapped to 0 .. 1
6161
62-
julia> axes(J)
62+
julia> axes(w)
6363
(Inclusion(0 .. 1),)
6464
65-
julia> J[0.5]
65+
julia> w[0.5]
6666
1.0
6767
```
6868
"""

src/classical/ultraspherical.jl

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11

22

33

4-
##
5-
# Ultraspherical
6-
##
7-
4+
"""
5+
UltrasphericalWeight{T}(a,b)
6+
UltrasphericalWeight(a,b)
7+
8+
The quasi-vector representing the Ultraspherical weight function ``(1-x^2)^{λ-1/2}`` on ``[-1,1]``. See also [`Ultraspherical`](@ref).
9+
# Examples
10+
```jldoctest
11+
julia> w = UltrasphericalWeight(1.0)
12+
(1-x^2)^0.5 on -1..1
13+
14+
julia> w[0.5]
15+
0.8660254037844386
16+
17+
julia> axes(w)
18+
(Inclusion(-1.0 .. 1.0 (Chebyshev)),)
19+
```
20+
"""
821
struct UltrasphericalWeight{T,Λ} <: AbstractJacobiWeight{T}
922
λ::Λ
1023
end
@@ -17,7 +30,7 @@ AbstractQuasiArray{T}(w::UltrasphericalWeight) where T = UltrasphericalWeight{T}
1730
AbstractQuasiVector{T}(w::UltrasphericalWeight) where T = UltrasphericalWeight{T}(w.λ)
1831

1932
show(io::IO, w::UltrasphericalWeight) = summary(io, w)
20-
summary(io::IO, w::UltrasphericalWeight) = print(io, "UltrasphericalWeight($(w.λ))")
33+
summary(io::IO, w::UltrasphericalWeight) = print(io, "(1-x^2)^$(w.λ-1/2) on -1..1")
2134

2235
==(a::UltrasphericalWeight, b::UltrasphericalWeight) = a.λ == b.λ
2336

@@ -30,6 +43,8 @@ sum(w::UltrasphericalWeight{T}) where T = sqrt(convert(T,π))*exp(loggamma(one(T
3043

3144
hasboundedendpoints(w::UltrasphericalWeight) = 2w.λ 1
3245

46+
broadcasted(::LazyQuasiArrayStyle{1}, ::typeof(sqrt), w::UltrasphericalWeight) = UltrasphericalWeight(w.λ/2 + one(w.λ)/4)
47+
3348

3449
struct Ultraspherical{T,Λ} <: AbstractJacobi{T}
3550
λ::Λ
@@ -308,3 +323,10 @@ end
308323
\(A::Ultraspherical, w_B::WeightedUltraspherical) = (UltrasphericalWeight(one(A.λ)/2) .* A) \ w_B
309324
\(A::Legendre, wB::WeightedUltraspherical) = Ultraspherical(A) \ wB
310325

326+
function \(P::OrthonormalWeighted{<:Any,<:Ultraspherical}, Q::OrthonormalWeighted{<:Any,<:Ultraspherical})
327+
@assert isone(2P.P.P.λ) # only Legendre is implemented
328+
@assert 2Q.P.P.λ == 5
329+
c = sqrt.(2*(5:2:∞) ./ ((3:∞) .* (4:∞) ))
330+
s = sqrt.(((1:∞) .* (2:∞)) ./ ((3:∞) .* (4:∞) ))
331+
-QRPackedQMatrix(BandedMatrix(-2 => -(s ./ (c .+ 1))), c .+ 1)
332+
end

test/test_ultraspherical.jl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,31 +207,33 @@ using ClassicalOrthogonalPolynomials: grammatrix, OrthonormalWeighted
207207

208208
@testset "orthonormal" begin
209209
P = OrthonormalWeighted(Ultraspherical(1/2))
210-
W = OrthonormalWeighted(Ultraspherical(3/2))
210+
W = OrthonormalWeighted(Ultraspherical(5/2))
211211
@test P'P == W'W == I
212-
P\W
212+
@test P[0.1,1:10] Normalized(Legendre())[0.1,1:10]
213+
@test W[0.1,1:10] (1 - 0.1.^2) * Normalized(Jacobi(2,2))[0.1,1:10]
214+
Q = P\W
213215

214-
Q = Normalized(Legendre()) \ (JacobiWeight(1,1) .* Normalized(Jacobi(2,2)))
216+
@test (Normalized(Legendre()) \ (JacobiWeight(1,1) .* Normalized(Jacobi(2,2))))[1:10,1:10] Q[1:10,1:10]
215217
@test Q[1:12,1:10]'Q[1:12,1:10] I
216218

217219
X = jacobimatrix(Normalized(Legendre()))
218-
@test Q[1:10,1:10] -qr(I - X^2).Q[1:10,1:10]
220+
@test Q[1:10,1:10] -qr(X^2 - I).Q[1:10,1:10]
219221

220-
c = sqrt.(2*(5:2:∞) ./ ((3:∞) .* (4:∞) ))
221-
s = sqrt.(((1:∞) .* (2:∞)) ./ ((3:∞) .* (4:∞) ))
222+
@testset "derivation" begin
223+
c = sqrt.(2*(5:2:∞) ./ ((3:∞) .* (4:∞) ))
224+
s = sqrt.(((1:∞) .* (2:∞)) ./ ((3:∞) .* (4:∞) ))
222225

223-
n = 10
224-
@test (c.^2 + s.^2)[1:n] ones(n)
225-
G = [Matrix(1.0I,n,n) for k=1:n-2]
226-
for k = 1:n-2
227-
G[k][[k,k+2],[k,k+2]] = [c[k] s[k]; -s[k] c[k]]
228-
end
229-
230-
@test Q[1:n,1:n-2] *(G...)[:,1:n-2]
231-
232-
@test qr(I - X^2).τ[1:10] c[1:10] .+ 1
233-
@test qr(I - X^2).factors[band(-2)][1:10] -(s ./ (c .+ 1))[1:10]
226+
n = 10
227+
@test (c.^2 + s.^2)[1:n] ones(n)
228+
G = [Matrix(1.0I,n,n) for k=1:n-2]
229+
for k = 1:n-2
230+
G[k][[k,k+2],[k,k+2]] = [c[k] s[k]; -s[k] c[k]]
231+
end
234232

235-
MatrixFactorizations.QRPackedQ(BandedMatrix(-2 => -(s ./ (c .+ 1))), c .+ 1)[1:10,1:10]
233+
@test Q[1:n,1:n-2] *(G...)[:,1:n-2]
234+
235+
@test qr(I - X^2).τ[1:10] c[1:10] .+ 1
236+
@test qr(I - X^2).factors[band(-2)][1:10] -(s ./ (c .+ 1))[1:10]
237+
end
236238
end
237239
end

0 commit comments

Comments
 (0)