Skip to content

Commit 1d6d223

Browse files
authored
Conversion between normalized Ultraspherical and Jacobi (#157)
* normalized Ultraspherical Jacobi conversion * version bump to v0.5.19
1 parent 85649d1 commit 1d6d223

File tree

4 files changed

+55
-41
lines changed

4 files changed

+55
-41
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunOrthogonalPolynomials"
22
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
3-
version = "0.5.18"
3+
version = "0.5.19"
44

55
[deps]
66
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"

src/Spaces/Jacobi/Jacobi.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ Jacobi(b,a) = Jacobi(b,a,ChebyshevInterval())
2121
Jacobi(A::Ultraspherical) = Jacobi(order(A)-0.5,order(A)-0.5,domain(A))
2222
Jacobi(A::Chebyshev) = Jacobi(-0.5,-0.5,domain(A))
2323

24-
NormalizedJacobi(b,a,d) = NormalizedPolynomialSpace(Jacobi(b,a,d))
25-
NormalizedJacobi(b,a) = NormalizedPolynomialSpace(Jacobi(b,a))
26-
NormalizedLegendre(d) = NormalizedPolynomialSpace(Legendre(d))
27-
NormalizedLegendre() = NormalizedPolynomialSpace(Legendre())
24+
NormalizedJacobi(s...) = NormalizedPolynomialSpace(Jacobi(s...))
25+
NormalizedLegendre(d...) = NormalizedPolynomialSpace(Legendre(d...))
2826

2927
normalization(::Type{T}, sp::Jacobi, k::Int) where T = FastTransforms.Anαβ(k, sp.a, sp.b)
3028

@@ -35,6 +33,10 @@ function Ultraspherical(J::Jacobi)
3533
error("Cannot construct Ultraspherical with a=$(J.a) and b=$(J.b)")
3634
end
3735
end
36+
NormalizedUltraspherical(NS::NormalizedPolynomialSpace{<:Jacobi}) =
37+
NormalizedPolynomialSpace(Ultraspherical(NS.space))
38+
NormalizedJacobi(NS::NormalizedPolynomialSpace{<:Union{Ultraspherical, Chebyshev}}) =
39+
NormalizedPolynomialSpace(Jacobi(NS.space))
3840

3941
Base.promote_rule(::Type{Jacobi{D,R1}},::Type{Jacobi{D,R2}}) where {D,R1,R2} =
4042
Jacobi{D,promote_type(R1,R2)}

src/Spaces/Ultraspherical/Ultraspherical.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ NormalizedUltraspherical(m,d) = NormalizedPolynomialSpace(Ultraspherical(m,d))
3131

3232

3333
order(S::Ultraspherical) = S.order
34+
order(N::NormalizedPolynomialSpace{<:Ultraspherical}) = order(N.space)
3435
setdomain(S::Ultraspherical,d::Domain) = Ultraspherical(order(S),d)
3536

3637

test/JacobiTest.jl

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,6 @@ using StaticArrays: SVector
4747
testtransforms(Jacobi(-0.5,-0.5))
4848
@test norm(Fun(Fun(exp),Jacobi(-.5,-.5))-Fun(exp,Jacobi(-.5,-.5))) < 300eps()
4949

50-
@testset "inplace transform" begin
51-
@testset for T in (Float32, Float64), ET in (T, complex(T))
52-
v = Array{ET}(undef, 10)
53-
v2 = similar(v)
54-
@testset for a in 0:0.5:3, b in 0:0.5:3, d in ((), (0..1,))
55-
J = Jacobi(a, b, d...)
56-
Slist = (J, NormalizedPolynomialSpace(J))
57-
@testset for S in Slist
58-
test_transform!(v, v2, S)
59-
end
60-
end
61-
v = Array{ET}(undef, 10, 10)
62-
v2 = similar(v)
63-
@testset for a in 0:0.5:3, b in 0:0.5:3, d in ((), (0..1,))
64-
J = Jacobi(a, b, d...)
65-
Slist = (J, NormalizedPolynomialSpace(J))
66-
@testset for S1 in Slist, S2 in Slist
67-
S = S1 S2
68-
test_transform!(v, v2, S)
69-
end
70-
@testset for S1 in Slist
71-
S = S1 Chebyshev(d...)
72-
test_transform!(v, v2, S)
73-
S = S1 Chebyshev()
74-
test_transform!(v, v2, S)
75-
end
76-
@testset for S2 in Slist
77-
S = Chebyshev(d...) S2
78-
test_transform!(v, v2, S)
79-
S = Chebyshev() S2
80-
test_transform!(v, v2, S)
81-
end
82-
end
83-
end
84-
end
85-
8650
@testset for d in [-1..1, 0..1]
8751
f = Fun(x->x^2, Chebyshev(d))
8852
C = space(f)
@@ -96,6 +60,53 @@ using StaticArrays: SVector
9660
end
9761
end
9862
end
63+
64+
@testset "conversion between spaces" begin
65+
for u in (Ultraspherical(1), Chebyshev())
66+
@test NormalizedPolynomialSpace(Jacobi(u)) ==
67+
NormalizedJacobi(NormalizedPolynomialSpace(u))
68+
end
69+
for j in (Legendre(), Jacobi(1,1))
70+
@test NormalizedPolynomialSpace(Ultraspherical(j)) ==
71+
NormalizedUltraspherical(NormalizedPolynomialSpace(j))
72+
end
73+
end
74+
end
75+
76+
@testset "inplace transform" begin
77+
@testset for T in (Float32, Float64), ET in (T, complex(T))
78+
v = Array{ET}(undef, 10)
79+
v2 = similar(v)
80+
@testset for a in 0:0.5:3, b in 0:0.5:3, d in ((), (0..1,))
81+
J = Jacobi(a, b, d...)
82+
Slist = (J, NormalizedPolynomialSpace(J))
83+
@testset for S in Slist
84+
test_transform!(v, v2, S)
85+
end
86+
end
87+
v = Array{ET}(undef, 10, 10)
88+
v2 = similar(v)
89+
@testset for a in 0:0.5:3, b in 0:0.5:3, d in ((), (0..1,))
90+
J = Jacobi(a, b, d...)
91+
Slist = (J, NormalizedPolynomialSpace(J))
92+
@testset for S1 in Slist, S2 in Slist
93+
S = S1 S2
94+
test_transform!(v, v2, S)
95+
end
96+
@testset for S1 in Slist
97+
S = S1 Chebyshev(d...)
98+
test_transform!(v, v2, S)
99+
S = S1 Chebyshev()
100+
test_transform!(v, v2, S)
101+
end
102+
@testset for S2 in Slist
103+
S = Chebyshev(d...) S2
104+
test_transform!(v, v2, S)
105+
S = Chebyshev() S2
106+
test_transform!(v, v2, S)
107+
end
108+
end
109+
end
99110
end
100111

101112
@testset "Derivative" begin

0 commit comments

Comments
 (0)