Skip to content

Commit

Permalink
Try both canonicalspaces in defaultConversion (#149)
Browse files Browse the repository at this point in the history
* try both canonicalspaces in default_conversion

* version bump to v0.6.6
  • Loading branch information
jishnub authored Aug 9, 2022
1 parent 6b7cbb1 commit 00b3e94
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunBase"
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
version = "0.6.5"
version = "0.6.6"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
31 changes: 21 additions & 10 deletions src/Operators/banded/Conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,32 @@ rangespace(C::ConcreteConversion)=C.rangespace




function _implementconversionerror(a, b)
error("Implement Conversion from ", typeof(a), " to ", typeof(b))
end
function _defaultConversion(a, spa, b)
if typeof(spa) == typeof(a)
spb = canonicalspace(b)
if typeof(spb) == typeof(a)
_implementconversionerror(spb, b)
elseif typeof(spb) == typeof(b)
_implementconversionerror(a, spb)
else
return _defaultConversion(a, spb, b)
end
elseif typeof(spa) == typeof(b)
_implementconversionerror(a, spa)
end
Conversion(a, spa, b)
end
function defaultConversion(a::Space,b::Space)
if a==b
Conversion(a)
elseif conversion_type(a,b)==NoSpace()
sp=canonicalspace(a)
if typeof(sp) == typeof(a)
error("Implement Conversion from " * string(typeof(sp)) * " to " * string(typeof(b)))
elseif typeof(sp) == typeof(b)
error("Implement Conversion from " * string(typeof(a)) * " to " * string(typeof(sp)))
else
Conversion(a,sp,b)
end
spa = canonicalspace(a)
_defaultConversion(a, spa, b)
else
error("Implement Conversion from " * string(typeof(a)) * " to " * string(typeof(b)))
_implementconversionerror(a, b)
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/SpacesTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,17 @@ using ApproxFunOrthogonalPolynomials
end
end
end

@testset "conversion" begin
C12 = Conversion(Chebyshev(), NormalizedLegendre())
C21 = Conversion(NormalizedLegendre(), Chebyshev())
@test Matrix((C12 * C21)[1:10, 1:10]) I
@test Matrix((C21 * C12)[1:10, 1:10]) I

C12 = Conversion(Chebyshev(), NormalizedPolynomialSpace(Ultraspherical(1)))
C1C2 = Conversion(Ultraspherical(1), NormalizedPolynomialSpace(Ultraspherical(1))) *
Conversion(Chebyshev(), Ultraspherical(1))
@test Matrix(C12[1:10, 1:10]) Matrix(C1C2[1:10, 1:10])
end
end
end

2 comments on commit 00b3e94

@jishnub
Copy link
Member Author

@jishnub jishnub commented on 00b3e94 Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65926

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.6 -m "<description of version>" 00b3e948d2221a4b35ca4254c94259a188340e49
git push origin v0.6.6

Please sign in to comment.