Skip to content

hasconversion for tensorspace #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunOrthogonalPolynomials"
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
version = "0.6.5"
version = "0.6.6"

[deps]
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
Expand Down
19 changes: 19 additions & 0 deletions src/Spaces/PolynomialSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,25 @@ hasconversion(a::PolynomialSpace,b::NormalizedPolynomialSpace) = hasconversion(a
hasconversion(a::NormalizedPolynomialSpace,b::PolynomialSpace) = hasconversion(a.space,b)
hasconversion(a::NormalizedPolynomialSpace,b::NormalizedPolynomialSpace) = hasconversion(a.space,b)

# Tensor products of normalized and unnormalized spaces may have banded conversions defined
# A banded conversion exists in special cases, where both conversion operators are diagonal
_stripnorm(N::NormalizedPolynomialSpace) = canonicalspace(N)
_stripnorm(x::PolynomialSpace) = x
function _hasconversion_tensor(A, B)
A1, A2 = A
B1, B2 = B

_stripnorm(A1) == _stripnorm(B1) && _stripnorm(A2) == _stripnorm(B2)
end
const MaybeNormalized{S<:PolynomialSpace} = Union{S, NormalizedPolynomialSpace{S}}
const MaybeNormalizedTensorSpace{P1,P2} = TensorSpace{<:Tuple{MaybeNormalized{P1},MaybeNormalized{P2}}}

function hasconversion(A::MaybeNormalizedTensorSpace{<:P1, <:P2},
B::MaybeNormalizedTensorSpace{<:P1, <:P2}) where {P1<:PolynomialSpace,P2<:PolynomialSpace}

_hasconversion_tensor(factors(A), factors(B))
end


function Multiplication(f::Fun{<:PolynomialSpace}, sp::NormalizedPolynomialSpace)
unnorm_sp = canonicalspace(sp)
Expand Down
10 changes: 10 additions & 0 deletions test/JacobiTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,14 @@ using Static
x = @inferred ApproxFunBase.conversion_rule(Jacobi(1,1), Jacobi(2,2))
@test x == Jacobi(1,1)
end

@testset "Tensor space conversions" begin
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), Chebyshev()*Legendre())
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), Chebyshev()*NormalizedLegendre())
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), NormalizedChebyshev()*Legendre())
@test ApproxFunBase.hasconversion(Chebyshev()*NormalizedLegendre(), Chebyshev()*Legendre())
@test ApproxFunBase.hasconversion(NormalizedChebyshev()*Legendre(), Chebyshev()*Legendre())
@test ApproxFunBase.hasconversion(NormalizedChebyshev()*NormalizedLegendre(), Chebyshev()*Legendre())
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), NormalizedChebyshev()*NormalizedLegendre())
end
end