Skip to content

Commit 5f975f9

Browse files
committed
add tests
1 parent 9b95b33 commit 5f975f9

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

src/classical/jacobi.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ end
482482
broadcastbasis(::typeof(+), w_A::Weighted{<:Any,<:Jacobi}, w_B::Weighted{<:Any,<:Jacobi}) = broadcastbasis(+, convert(WeightedBasis,w_A), convert(WeightedBasis,w_B))
483483
broadcastbasis(::typeof(+), w_A::Weighted{<:Any,<:Jacobi}, w_B::WeightedJacobi) = broadcastbasis(+, convert(WeightedBasis,w_A), w_B)
484484
broadcastbasis(::typeof(+), w_A::WeightedJacobi, w_B::Weighted{<:Any,<:Jacobi}) = broadcastbasis(+, w_A, convert(WeightedBasis,w_B))
485-
broadcastbasis(::typeof(+), A::Jacobi, B::Weighted{<:Any,<:Jacobi}) = A # assume B can be lowered to Legendre... for now
486-
broadcastbasis(::typeof(+), A::Weighted{<:Any,<:Jacobi}, B::Jacobi) = B # assume B can be lowered to Legendre... for now
485+
broadcastbasis(::typeof(+), A::Jacobi, B::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}) = A
486+
broadcastbasis(::typeof(+), A::Weighted{<:Any,<:Jacobi{<:Any,<:Integer}}, B::Jacobi) = B
487487

488488
function \(w_A::WeightedJacobi, w_B::WeightedJacobi)
489489
wA,A = w_A.args

test/test_jacobi.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,19 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, basis, MulQuasiMa
537537
@testset "conversion not implemented" begin
538538
@test_throws ArgumentError Jacobi(0,0) \ Jacobi(1.1,2.1)
539539
end
540+
541+
@testset "broadcastbasis" begin
542+
a = Jacobi(1,1) * [1; zeros(∞)]
543+
b = Weighted(Jacobi(1,1)) * [1; zeros(∞)]
544+
c = Weighted(Jacobi(2,3)) * [1; zeros(∞)]
545+
546+
@test basis(a+b) == basis(b+a) == basis(a+c) == basis(c+a) == Jacobi(1,1)
547+
@test a[0.1]+b[0.1] (a+b)[0.1] (b+a)[0.1]
548+
end
549+
550+
@testset "Weighted expand" begin
551+
W = Weighted(Jacobi(1,1))
552+
@test expand(W, x -> (1-x^2)*exp(x))[0.1] (1-0.1^2)*exp(0.1)
553+
@test grid(W, 5) == grid(W.P, 5)
554+
end
540555
end

test/test_lanczos.jl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,23 @@ import ClassicalOrthogonalPolynomials: recurrencecoefficients, PaddedColumns, or
303303
@test jacobimatrix(Q)[1,1] 1/3
304304
@test Q[0.5,1:3] [1, 1.369306393762913, 0.6469364618834543]
305305
end
306-
end
307-
308-
@testset "#197" begin
309-
@test _emptymaximum(1:5) == 5
310-
@test _emptymaximum(1:0) == 0
311-
x = Inclusion(ChebyshevInterval())
312-
f = exp.(x)
313-
QQ = LanczosPolynomial(f)
314-
R = LanczosConversion(QQ.data)
315-
v = cache(Zeros(∞))
316-
@test (R \ v)[1:500] == zeros(500)
317-
@test (R * v)[1:500] == zeros(500)
306+
307+
@testset "#197" begin
308+
@test _emptymaximum(1:5) == 5
309+
@test _emptymaximum(1:0) == 0
310+
x = Inclusion(ChebyshevInterval())
311+
f = exp.(x)
312+
QQ = LanczosPolynomial(f)
313+
R = LanczosConversion(QQ.data)
314+
v = cache(Zeros(∞))
315+
@test (R \ v)[1:500] == zeros(500)
316+
@test (R * v)[1:500] == zeros(500)
317+
end
318+
319+
@testset "diff" begin
320+
P = Normalized(Legendre())
321+
x = axes(P,1)
322+
Q = LanczosPolynomial(exp.(x))
323+
@test diff(Q)[0.1,3] -0.1637907411174539
324+
end
318325
end

0 commit comments

Comments
 (0)