Skip to content

Commit 00b3e94

Browse files
authored
Try both canonicalspaces in defaultConversion (#149)
* try both canonicalspaces in default_conversion * version bump to v0.6.6
1 parent 6b7cbb1 commit 00b3e94

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.6.5"
3+
version = "0.6.6"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Operators/banded/Conversion.jl

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,32 @@ rangespace(C::ConcreteConversion)=C.rangespace
2525

2626

2727

28-
28+
function _implementconversionerror(a, b)
29+
error("Implement Conversion from ", typeof(a), " to ", typeof(b))
30+
end
31+
function _defaultConversion(a, spa, b)
32+
if typeof(spa) == typeof(a)
33+
spb = canonicalspace(b)
34+
if typeof(spb) == typeof(a)
35+
_implementconversionerror(spb, b)
36+
elseif typeof(spb) == typeof(b)
37+
_implementconversionerror(a, spb)
38+
else
39+
return _defaultConversion(a, spb, b)
40+
end
41+
elseif typeof(spa) == typeof(b)
42+
_implementconversionerror(a, spa)
43+
end
44+
Conversion(a, spa, b)
45+
end
2946
function defaultConversion(a::Space,b::Space)
3047
if a==b
3148
Conversion(a)
3249
elseif conversion_type(a,b)==NoSpace()
33-
sp=canonicalspace(a)
34-
if typeof(sp) == typeof(a)
35-
error("Implement Conversion from " * string(typeof(sp)) * " to " * string(typeof(b)))
36-
elseif typeof(sp) == typeof(b)
37-
error("Implement Conversion from " * string(typeof(a)) * " to " * string(typeof(sp)))
38-
else
39-
Conversion(a,sp,b)
40-
end
50+
spa = canonicalspace(a)
51+
_defaultConversion(a, spa, b)
4152
else
42-
error("Implement Conversion from " * string(typeof(a)) * " to " * string(typeof(b)))
53+
_implementconversionerror(a, b)
4354
end
4455
end
4556

test/SpacesTest.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,17 @@ using ApproxFunOrthogonalPolynomials
205205
end
206206
end
207207
end
208+
209+
@testset "conversion" begin
210+
C12 = Conversion(Chebyshev(), NormalizedLegendre())
211+
C21 = Conversion(NormalizedLegendre(), Chebyshev())
212+
@test Matrix((C12 * C21)[1:10, 1:10]) I
213+
@test Matrix((C21 * C12)[1:10, 1:10]) I
214+
215+
C12 = Conversion(Chebyshev(), NormalizedPolynomialSpace(Ultraspherical(1)))
216+
C1C2 = Conversion(Ultraspherical(1), NormalizedPolynomialSpace(Ultraspherical(1))) *
217+
Conversion(Chebyshev(), Ultraspherical(1))
218+
@test Matrix(C12[1:10, 1:10]) Matrix(C1C2[1:10, 1:10])
219+
end
208220
end
209221
end

0 commit comments

Comments
 (0)