Skip to content

Commit c881b28

Browse files
authored
Implement T'U (and U'T) (#97)
* Implement T'U (and U'T) * Add T'T * Update test_chebyshev.jl
1 parent 4d9bfd7 commit c881b28

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ClassicalOrthogonalPolynomials"
22
uuid = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.6.2"
4+
version = "0.6.3"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -39,7 +39,7 @@ HypergeometricFunctions = "0.3.4"
3939
InfiniteArrays = "0.12.3"
4040
InfiniteLinearAlgebra = "0.6.7"
4141
IntervalSets = "0.5, 0.6, 0.7"
42-
LazyArrays = "0.22"
42+
LazyArrays = "0.22.11"
4343
LazyBandedMatrices = "0.7.14"
4444
QuasiArrays = "0.9"
4545
SpecialFunctions = "1.0, 2"

src/classical/chebyshev.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ massmatrix(::ChebyshevU{V}) where V = Diagonal(Fill(convert(V,π)/2,∞))
148148
@simplify *(A::QuasiAdjoint{<:Any,<:Weighted{<:Any,<:ChebyshevT}}, B::ChebyshevT) = massmatrix(ChebyshevT{promote_type(eltype(A),eltype(B))}())
149149
@simplify *(A::QuasiAdjoint{<:Any,<:Weighted{<:Any,<:ChebyshevU}}, B::ChebyshevU) = massmatrix(ChebyshevU{promote_type(eltype(A),eltype(B))}())
150150

151+
@simplify function *(A::QuasiAdjoint{<:Any,<:ChebyshevT}, B::ChebyshevT)
152+
T = promote_type(eltype(A), eltype(B))
153+
f = (k,j) -> isodd(j-k) ? zero(T) : -(((1 + (-1)^(j + k))*(-1 + j^2 + k^2))/(j^4 + (-1 + k^2)^2 - 2j^2*(1 + k^2)))
154+
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
155+
end
156+
157+
@simplify function *(A::QuasiAdjoint{<:Any,<:ChebyshevT}, B::ChebyshevU)
158+
T = promote_type(eltype(A), eltype(B))
159+
f = (k,j) -> isodd(j-k) ? zero(T) : ((one(T) + (-1)^(j + k))*(1 + j))/((1 + j - k)*(1 + j + k))
160+
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
161+
end
162+
163+
164+
151165
##########
152166
# Derivatives
153167
##########

test/test_chebyshev.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,18 @@ import ContinuumArrays: MappedWeightedBasisLayout, Map, WeightedBasisLayout
456456
T = ChebyshevT()
457457
@test ChebyshevT{ComplexF64}() convert(AbstractQuasiArray{ComplexF64}, T) convert(AbstractQuasiMatrix{ComplexF64}, T)
458458
end
459+
460+
@testset "innerproduct" begin
461+
T = ChebyshevT()
462+
U = ChebyshevU()
463+
x = axes(T,1)
464+
465+
@test (T'U)[1:10,1:10] (U'T)[1:10,1:10]'
466+
@test (T'T)[1:10,1:10] ((T'U)*(U\T))[1:10,1:10]
467+
@test_broken (U'U)[1:10,1:10] ((U'T)*(T\U))[1:10,1:10]
468+
f,g = (T/T\exp.(x)),(U/U\exp.(x))
469+
@test f'g g'f f'f dot(f,g) dot(f,f) exp(2)/2 - exp(-2)/2
470+
end
459471
end
460472

461473
struct QuadraticMap{T} <: Map{T} end

0 commit comments

Comments
 (0)