Skip to content

Commit 186d9e8

Browse files
committed
Update test_monic.jl
1 parent 37f4058 commit 186d9e8

File tree

1 file changed

+53
-50
lines changed

1 file changed

+53
-50
lines changed

test/test_monic.jl

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,60 @@ using ClassicalOrthogonalPolynomials
22
using Test
33
using ClassicalOrthogonalPolynomials: Monic, _p0, orthogonalityweight, recurrencecoefficients
44

5-
@testset "Basic definition" begin
6-
P1 = Legendre()
7-
P2 = Normalized(P1)
8-
P3 = Monic(P1)
9-
@test P3.P == P2
10-
@test Monic(P3) === P3
11-
@test axes(P3) == axes(Legendre())
12-
@test Normalized(P3) === P3.P
13-
@test _p0(P3) == 1
14-
@test orthogonalityweight(P3) == orthogonalityweight(P1)
15-
@test sprint(show, MIME"text/plain"(), P3) == "Monic(Legendre())"
16-
end
5+
@testset "Monic" begin
6+
@testset "Basic definition" begin
7+
P1 = Legendre()
8+
P2 = Normalized(P1)
9+
P3 = Monic(P1)
10+
@test P3.P == P2
11+
@test Monic(P3) === P3
12+
@test axes(P3) == axes(Legendre())
13+
@test Normalized(P3) === P3.P
14+
@test _p0(P3) == 1
15+
@test orthogonalityweight(P3) == orthogonalityweight(P1)
16+
@test sprint(show, MIME"text/plain"(), P3) == "Monic(Legendre())"
17+
end
1718

18-
@testset "evaluation" begin
19-
function _pochhammer(x, n)
20-
y = one(x)
21-
for i in 0:(n-1)
22-
y *= (x + i)
19+
@testset "evaluation" begin
20+
function _pochhammer(x, n)
21+
y = one(x)
22+
for i in 0:(n-1)
23+
y *= (x + i)
24+
end
25+
return y
26+
end
27+
jacobi_kn = (α, β, n) -> _pochhammer(n + α + β + 1, n) / (2.0^n * factorial(n))
28+
ultra_kn = (λ, n) -> 2^n * _pochhammer(λ, n) / factorial(n)
29+
chebt_kn = n -> n == 0 ? 1.0 : 2.0 .^ (n - 1)
30+
chebu_kn = n -> 2.0^n
31+
leg_kn = n -> 2.0^n * _pochhammer(1 / 2, n) / factorial(n)
32+
lag_kn = n -> (-1)^n / factorial(n)
33+
herm_kn = n -> 2.0^n
34+
_Jacobi(α, β, x, n) = Jacobi(α, β)[x, n+1] / jacobi_kn(α, β, n)
35+
_Ultraspherical(λ, x, n) = Ultraspherical(λ)[x, n+1] / ultra_kn(λ, n)
36+
_ChebyshevT(x, n) = ChebyshevT()[x, n+1] / chebt_kn(n)
37+
_ChebyshevU(x, n) = ChebyshevU()[x, n+1] / chebu_kn(n)
38+
_Legendre(x, n) = Legendre()[x, n+1] / leg_kn(n)
39+
_Laguerre(α, x, n) = Laguerre(α)[x, n+1] / lag_kn(n)
40+
_Hermite(x, n) = Hermite()[x, n+1] / herm_kn(n)
41+
Ps = [
42+
Jacobi(2.0, 5.0) (x, n)->_Jacobi(2.0, 5.0, x, n)
43+
Ultraspherical(1.7) (x, n)->_Ultraspherical(1.7, x, n)
44+
ChebyshevT() _ChebyshevT
45+
ChebyshevU() _ChebyshevU
46+
Legendre() _Legendre
47+
Laguerre(1.5) (x, n)->_Laguerre(1.5, x, n)
48+
Hermite() _Hermite
49+
]
50+
for (P, _P) in eachrow(Ps)
51+
@show P
52+
Q = Monic(P)
53+
@test Q[0.2, 1] == 1.0
54+
@test Q[0.25, 2] _P(0.25, 1)
55+
@test Q[0.17, 3] _P(0.17, 2)
56+
@test Q[0.4, 17] _P(0.4, 16)
57+
@test Q[0.9, 21] _P(0.9, 20)
58+
# @inferred Q[0.2, 5] # no longer inferred
2359
end
24-
return y
25-
end
26-
jacobi_kn = (α, β, n) -> _pochhammer(n + α + β + 1, n) / (2.0^n * factorial(n))
27-
ultra_kn = (λ, n) -> 2^n * _pochhammer(λ, n) / factorial(n)
28-
chebt_kn = n -> n == 0 ? 1.0 : 2.0 .^ (n - 1)
29-
chebu_kn = n -> 2.0^n
30-
leg_kn = n -> 2.0^n * _pochhammer(1 / 2, n) / factorial(n)
31-
lag_kn = n -> (-1)^n / factorial(n)
32-
herm_kn = n -> 2.0^n
33-
_Jacobi(α, β, x, n) = Jacobi(α, β)[x, n+1] / jacobi_kn(α, β, n)
34-
_Ultraspherical(λ, x, n) = Ultraspherical(λ)[x, n+1] / ultra_kn(λ, n)
35-
_ChebyshevT(x, n) = ChebyshevT()[x, n+1] / chebt_kn(n)
36-
_ChebyshevU(x, n) = ChebyshevU()[x, n+1] / chebu_kn(n)
37-
_Legendre(x, n) = Legendre()[x, n+1] / leg_kn(n)
38-
_Laguerre(α, x, n) = Laguerre(α)[x, n+1] / lag_kn(n)
39-
_Hermite(x, n) = Hermite()[x, n+1] / herm_kn(n)
40-
Ps = [
41-
Jacobi(2.0, 5.0) (x, n)->_Jacobi(2.0, 5.0, x, n)
42-
Ultraspherical(1.7) (x, n)->_Ultraspherical(1.7, x, n)
43-
ChebyshevT() _ChebyshevT
44-
ChebyshevU() _ChebyshevU
45-
Legendre() _Legendre
46-
Laguerre(1.5) (x, n)->_Laguerre(1.5, x, n)
47-
Hermite() _Hermite
48-
]
49-
for (P, _P) in eachrow(Ps)
50-
Q = Monic(P)
51-
@test Q[0.2, 1] == 1.0
52-
@test Q[0.25, 2] _P(0.25, 1)
53-
@test Q[0.17, 3] _P(0.17, 2)
54-
@test Q[0.4, 17] _P(0.4, 16)
55-
@test Q[0.9, 21] _P(0.9, 20)
56-
# @inferred Q[0.2, 5] # no longer inferred
5760
end
5861
end

0 commit comments

Comments
 (0)