Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ClassicalOrthogonalPolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
C*jacobimatrix(C)
end

function layout_broadcasted(::Tuple{ScalarLayout,AbstractOPLayout}, ::typeof(*), c, C)
C * c

Check warning on line 259 in src/ClassicalOrthogonalPolynomials.jl

View check run for this annotation

Codecov / codecov/patch

src/ClassicalOrthogonalPolynomials.jl#L258-L259

Added lines #L258 - L259 were not covered by tests
end


# function broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), a::BroadcastQuasiVector, C::OrthogonalPolynomial)
# axes(a,1) == axes(C,1) || throw(DimensionMismatch())
Expand Down
4 changes: 4 additions & 0 deletions src/classical/jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@
broadcastbasis(::typeof(+), A::Jacobi, B::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}) = A
broadcastbasis(::typeof(+), A::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}, B::Jacobi) = B

broadcasted(::LazyQuasiArrayStyle{2}, ::typeof(*), w::AbstractJacobiWeight, v::WeightedJacobi) =

Check warning on line 488 in src/classical/jacobi.jl

View check run for this annotation

Codecov / codecov/patch

src/classical/jacobi.jl#L488

Added line #L488 was not covered by tests
(w .* v.args[1]) .* v.args[2]


function \(w_A::WeightedJacobi, w_B::WeightedJacobi)
wA,A = w_A.args
wB,B = w_B.args
Expand Down
26 changes: 26 additions & 0 deletions test/test_jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,30 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
@test expand(W, x -> (1-x^2)*exp(x))[0.1] ≈ (1-0.1^2)*exp(0.1)
@test grid(W, 5) == grid(W.P, 5)
end

@testset "ladder operators" begin
a,b = 0.1,0.2
P = Jacobi(a,b)
A₊,A₋ = Jacobi(a+1,b),Jacobi(a-1,b)
B₊,B₋ = Jacobi(a,b+1),Jacobi(a,b-1)
C₊,C₋ = Jacobi(a+1,b+1),Jacobi(a-1,b-1)
D₊,D₋ = Jacobi(a+1,b-1), Jacobi(a-1,b+1)
t,n = 0.3,5
x = axes(P,1)
D = Derivative(P)

@test (D*P)[t,n+1] ≈ (n+a+b+1)/2 * C₊[t,n] # L₁
@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₂
@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₃
@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₄
@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₅
@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₆

@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₁'
@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₂'
@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₃'
@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₄'
@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₅'
@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₆'
end
end
31 changes: 31 additions & 0 deletions test/test_ultraspherical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,35 @@ using ClassicalOrthogonalPolynomials: grammatrix
@test (C \ diff(U,1))[1:10,1:10] == (C \ diff(U))[1:10,1:10]
@test (C³ \ diff(U,2))[1:10,1:10] == (C³ \ diff(diff(U)))[1:10,1:10]
end

@testset "ladder" begin
λ = 3/4
P = Jacobi(λ-1/2,λ-1/2)
W = Jacobi(λ-1-1/2,λ-1-1/2)
Q = Jacobi(λ+1-1/2,λ+1-1/2)
# a+ b = 2λ-1
D = Derivative(P)
x,n = 0.3,5
# L₁
@test (D*P)[t,n+1] ≈ (n+2λ)/2 * Q[t,n] # L₁
# L₃L₂
@test -(JacobiWeight(-(2λ+n),0) .* (D * (JacobiWeight(2λ+n+1,-(2λ+n-1)) .* D * (JacobiWeight(0,2λ+n) .* P))))[x,n+1] ≈
(n + 2λ)*(1 + n + 2λ) * P[x,n+1] + 2x*(1+n+2λ)* diff(P)[x,n+1] + (x^2-1) * diff(P,2)[x,n+1] ≈ (n+2λ)*(n+2λ+1)*Q[x,n+1]
# L₄'L₃ == L₅'L₂
@test -(JacobiWeight(0,n+1) .* (D * (JacobiWeight(-(2λ+n-1),-n) .* D * (JacobiWeight(2λ+n,0) .* P))))[x,n+1] ≈
(JacobiWeight(n+1,0) .* (D * (JacobiWeight(-n,-(2λ+n-1)) .* D * (JacobiWeight(0,2λ+n) .* P))))[x,n+1] ≈
-n * (n + 2λ) * P[x,n+1] + (1 + 2n + x + 2λ + 2x*λ)* diff(P)[x,n+1] + (x^2-1) * diff(P,2)[x,n+1] ≈
n * (n + 2λ) * P[x,n+1] + (1 + 2n - x + 2λ - 2x*λ)* diff(P)[x,n+1] + (1-x^2) * diff(P,2)[x,n+1] ≈ (n+2λ)*(n+λ+1/2)*Q[x,n]
# L₅'L₄' == L₄'L₅'
@test (JacobiWeight(n,0) .* (D * (JacobiWeight(1-n,n+1) .* D * (JacobiWeight(0,-n) .* P))))[x,n+1] ≈
(JacobiWeight(0,n) .* (D * (JacobiWeight(n+1,1-n) .* D * (JacobiWeight(-n,0) .* P))))[x,n+1] ≈
-n * (n - 1) * P[x,n+1] + 2x * (n-1)* diff(P)[x,n+1] - (x^2-1) * diff(P,2)[x,n+1] ≈
(n+λ-1/2)^2*Q[x,n-1]

P = Ultraspherical(λ)
Q = Ultraspherical(λ+1)
# L₃L₂
@test (n + 2λ)*(1 + n + 2λ) * P[t,n+1] + 2t*(1+n+2λ)* diff(P)[t,n+1] + (t^2-1) * diff(P,2)[t,n+1] ≈ 2λ*(1 + 2n + 2λ)Q[t,n+1]

end
end
Loading