Skip to content

Commit d280bda

Browse files
committed
Add tests for the Jacobi ladder operators
1 parent 8462dd4 commit d280bda

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/ClassicalOrthogonalPolynomials.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ function layout_broadcasted(::Tuple{PolynomialLayout,AbstractOPLayout}, ::typeof
255255
C*jacobimatrix(C)
256256
end
257257

258+
function layout_broadcasted(::Tuple{ScalarLayout,AbstractOPLayout}, ::typeof(*), c, C)
259+
C * c
260+
end
261+
258262

259263
# function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), a::BroadcastQuasiVector, C::OrthogonalPolynomial)
260264
# axes(a,1) == axes(C,1) || throw(DimensionMismatch())

test/test_jacobi.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,30 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
552552
@test expand(W, x -> (1-x^2)*exp(x))[0.1] (1-0.1^2)*exp(0.1)
553553
@test grid(W, 5) == grid(W.P, 5)
554554
end
555+
556+
@testset "ladder operators" begin
557+
a,b = 0.1,0.2
558+
P = Jacobi(a,b)
559+
A₊,A₋ = Jacobi(a+1,b),Jacobi(a-1,b)
560+
B₊,B₋ = Jacobi(a,b+1),Jacobi(a,b-1)
561+
C₊,C₋ = Jacobi(a+1,b+1),Jacobi(a-1,b-1)
562+
D₊,D₋ = Jacobi(a+1,b-1), Jacobi(a-1,b+1)
563+
t,n = 0.3,5
564+
x = axes(P,1)
565+
D = Derivative(P)
566+
567+
@test (D*P)[t,n+1] (n+a+b+1)/2 * C₊[t,n] # L₁
568+
@test (((a+b+n+1)*I + (1 .+ x) .* D)*P)[t,n+1] (JacobiWeight(0,-(a+b+n)) .* D * (JacobiWeight(0,a+b+n+1) .* P))[t,n+1] (n+a+b+1) * A₊[t,n+1] # L₂
569+
@test (((a+b+n+1)*I - (1 .- x) .* D)*P)[t,n+1] -(JacobiWeight(-(a+b+n),0) .* D * (JacobiWeight(a+b+n+1,0) .* P))[t,n+1] (n+a+b+1) * B₊[t,n+1] # L₃
570+
@test ((1 .+ t)*a - (1 .- t)*(b+n+1))*P[t,n+1] - (((1 .- x.^2) .* D)*P)[t,n+1] -(JacobiWeight(1-a,-(b+n)) .* D * (JacobiWeight(a,b+n+1) .* P))[t,n+1] 2*(n+1) * A₋[t,n+2] # L₄
571+
@test ((1 .+ t)*(a+n+1) - (1 .- t)*b)*P[t,n+1] - (((1 .- x.^2) .* D)*P)[t,n+1] -(JacobiWeight(-(a+n),1-b) .* D * (JacobiWeight(a+n+1,b) .* P))[t,n+1] 2*(n+1) * B₋[t,n+2] # L₅
572+
@test ((b*I + (1 .+ x) .* D)*P)[t,n+1] (JacobiWeight(0,1-b) .* D * (JacobiWeight(0,b) .* P))[t,n+1] (n+b) * D₊[t,n+1] # L₆
573+
574+
@test ((1 .+ t)*a - (1 .- t)*b)*P[t,n+1] - (((1 .- x.^2) .* D)*P)[t,n+1] -(JacobiWeight(1-a,1-b) .* D * (JacobiWeight(a,b) .* P))[t,n+1] 2*(n+1) * C₋[t,n+2] # L₁'
575+
@test (2a + (1 .- t)*n)*P[t,n+1] - (((1 .- x.^2) .* D)*P)[t,n+1] -(JacobiWeight(1-a,1+a+n) .* D * (JacobiWeight(a,-a-n) .* P))[t,n+1] 2*(n+a) * A₋[t,n+1] # L₂'
576+
@test (2b + (1 .+ t)*n)*P[t,n+1] + (((1 .- x.^2) .* D)*P)[t,n+1] (JacobiWeight(1+b+n,1-b) .* D * (JacobiWeight(-b-n,b) .* P))[t,n+1] 2*(n+b) * B₋[t,n+1] # L₃'
577+
@test ((-n*I + (1 .+ x) .* D)*P)[t,n+1] (JacobiWeight(0,n+1) .* D * (JacobiWeight(0,-n) .* P))[t,n+1] (n+b) * A₊[t,n] # L₄'
578+
@test ((n*I + (1 .- x) .* D)*P)[t,n+1] (JacobiWeight(n+1,0) .* D * (JacobiWeight(-n,0) .* P))[t,n+1] (n+a) * B₊[t,n] # L₅'
579+
@test ((a*I - (1 .- x) .* D)*P)[t,n+1] -(JacobiWeight(1-a,0) .* D * (JacobiWeight(a,0) .* P))[t,n+1] (n+a) * D₋[t,n+1] # L₆'
580+
end
555581
end

0 commit comments

Comments
 (0)