Skip to content

Commit 1e7e6d3

Browse files
authored
Disallow banded Ultraspherical conversion from n+1 to n (#308)
* Disallow banded Ultraspherical conversion from n+1 to n * Add bandwidth test for HalfOddInt
1 parent 8b82770 commit 1e7e6d3

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
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.6.45"
3+
version = "0.6.46"
44

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

src/Spaces/Ultraspherical/UltrasphericalOperators.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function Conversion(A::Ultraspherical,B::Ultraspherical)
174174
if b==a
175175
return ConversionWrapper(Operator(I,A))
176176
elseif isapproxinteger(b-a) || isapproxhalfoddinteger(b-a)
177-
if -1 b-a 1 && (a,b) (2,1)
177+
if -0.5 b-a 1 # -0.5, 0.5 or 1
178178
return ConcreteConversion(A,B)
179179
elseif b-a > 1
180180
r = b:-1:a+1
@@ -251,6 +251,7 @@ end
251251

252252
bandwidths(C::ConcreteConversion{<:Chebyshev,<:Ultraspherical{<:Integer}}) = 0,2 # order == 1
253253
bandwidths(C::ConcreteConversion{<:Ultraspherical{<:Integer},<:Ultraspherical{<:Integer}}) = 0,2
254+
bandwidths(C::ConcreteConversion{<:Ultraspherical{<:HalfOddInteger},<:Ultraspherical{<:HalfOddInteger}}) = 0,2
254255

255256
function bandwidths(C::ConcreteConversion{<:Chebyshev,<:Ultraspherical})
256257
orderone = order(rangespace(C)) == 1

test/UltrasphericalTest.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ include("testutils.jl")
3838
end
3939
@testset "Conversion" begin
4040
# Tests whether invalid/unimplemented arguments correctly throws ArgumentError
41+
@test_throws ArgumentError Conversion(Ultraspherical(3), Ultraspherical(2))
4142
@test_throws ArgumentError Conversion(Ultraspherical(2), Ultraspherical(1))
4243
@test_throws ArgumentError Conversion(Ultraspherical(3), Ultraspherical(1.9))
4344

@@ -140,14 +141,26 @@ include("testutils.jl")
140141
ff = x->x^2 +2x^3 + 3x^4
141142
for n1 in (0.5, 1)
142143
f = Fun(ff, Ultraspherical(n1))
143-
for n2 in (2.5, 3)
144+
for n2 in (1.5, 2.5, 3)
144145
CLU = Conversion(Ultraspherical(n1), Ultraspherical(n2))
145146
@test !isdiag(CLU)
146147
g = CLU * f
147-
@test g Fun(ff, Ultraspherical(n1))
148+
@test g Fun(ff, Ultraspherical(n2))
148149
end
149150
end
150151

152+
for n1 in (0.5, half(Odd(1)), 1)
153+
f = Fun(ff, Ultraspherical(n1))
154+
for n2 in (1, 0.5, half(Odd(1)))
155+
CLU = Conversion(Ultraspherical(n1), Ultraspherical(n2))
156+
g = CLU * f
157+
@test g Fun(ff, Ultraspherical(n2))
158+
end
159+
end
160+
161+
C = Conversion(Ultraspherical(half(Odd(1))), Ultraspherical(half(Odd(3))))
162+
@test @inferred (C -> Val(bandwidths(C)))(C) == Val((0,2))
163+
151164
@testset "Normalized" begin
152165
Tallowed = Union{
153166
typeof(Conversion(Ultraspherical(1), NormalizedUltraspherical(1))),

0 commit comments

Comments
 (0)