Skip to content

Commit 139fee6

Browse files
authored
W'W and W'T mass matrices (#99)
1 parent c881b28 commit 139fee6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/classical/chebyshev.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ end
162162

163163

164164

165+
@simplify function *(A::QuasiAdjoint{<:Any,<:Weighted{<:Any,<:ChebyshevU}}, B::Weighted{<:Any,<:ChebyshevU})
166+
T = promote_type(eltype(A), eltype(B))
167+
f = (k,j) -> isodd(j-k) ? zero(T) : -((2*(one(T) + (-1)^(j + k))*(1 + j)*(1 + k))/((-1 + j - k)*(1 + j - k)*(1 + j + k)*(3 + j + k)))
168+
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
169+
end
170+
171+
172+
@simplify function *(A::QuasiAdjoint{<:Any,<:Weighted{<:Any,<:ChebyshevU}}, B::ChebyshevT)
173+
T = promote_type(eltype(A), eltype(B))
174+
W = parent(A)
175+
U = ChebyshevU{T}()
176+
(W'U) * (U\B)
177+
end
178+
179+
165180
##########
166181
# Derivatives
167182
##########

test/test_chebyshev.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,18 @@ import ContinuumArrays: MappedWeightedBasisLayout, Map, WeightedBasisLayout
460460
@testset "innerproduct" begin
461461
T = ChebyshevT()
462462
U = ChebyshevU()
463+
W = Weighted(U)
463464
x = axes(T,1)
464465

465466
@test (T'U)[1:10,1:10] (U'T)[1:10,1:10]'
466467
@test (T'T)[1:10,1:10] ((T'U)*(U\T))[1:10,1:10]
467468
@test_broken (U'U)[1:10,1:10] ((U'T)*(T\U))[1:10,1:10]
468469
f,g = (T/T\exp.(x)),(U/U\exp.(x))
469470
@test f'g g'f f'f dot(f,g) dot(f,f) exp(2)/2 - exp(-2)/2
471+
472+
h = W * (U\exp.(x))
473+
@test h'h cosh(2) - sinh(2)/2
474+
@test f'h h'f 2.498566528528904 # 1/2 π BesselI[1, 2]
470475
end
471476
end
472477

0 commit comments

Comments
 (0)