Skip to content

Commit 26f8f70

Browse files
authored
hasconversion for tensorspace (#176)
* hasconversion for tensorspace * undo conversion_type * version bump to v0.6.6
1 parent 72b4eb4 commit 26f8f70

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
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.5"
3+
version = "0.6.6"
44

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

src/Spaces/PolynomialSpace.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,25 @@ hasconversion(a::PolynomialSpace,b::NormalizedPolynomialSpace) = hasconversion(a
456456
hasconversion(a::NormalizedPolynomialSpace,b::PolynomialSpace) = hasconversion(a.space,b)
457457
hasconversion(a::NormalizedPolynomialSpace,b::NormalizedPolynomialSpace) = hasconversion(a.space,b)
458458

459+
# Tensor products of normalized and unnormalized spaces may have banded conversions defined
460+
# A banded conversion exists in special cases, where both conversion operators are diagonal
461+
_stripnorm(N::NormalizedPolynomialSpace) = canonicalspace(N)
462+
_stripnorm(x::PolynomialSpace) = x
463+
function _hasconversion_tensor(A, B)
464+
A1, A2 = A
465+
B1, B2 = B
466+
467+
_stripnorm(A1) == _stripnorm(B1) && _stripnorm(A2) == _stripnorm(B2)
468+
end
469+
const MaybeNormalized{S<:PolynomialSpace} = Union{S, NormalizedPolynomialSpace{S}}
470+
const MaybeNormalizedTensorSpace{P1,P2} = TensorSpace{<:Tuple{MaybeNormalized{P1},MaybeNormalized{P2}}}
471+
472+
function hasconversion(A::MaybeNormalizedTensorSpace{<:P1, <:P2},
473+
B::MaybeNormalizedTensorSpace{<:P1, <:P2}) where {P1<:PolynomialSpace,P2<:PolynomialSpace}
474+
475+
_hasconversion_tensor(factors(A), factors(B))
476+
end
477+
459478

460479
function Multiplication(f::Fun{<:PolynomialSpace}, sp::NormalizedPolynomialSpace)
461480
unnorm_sp = canonicalspace(sp)

test/JacobiTest.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,4 +545,14 @@ using Static
545545
x = @inferred ApproxFunBase.conversion_rule(Jacobi(1,1), Jacobi(2,2))
546546
@test x == Jacobi(1,1)
547547
end
548+
549+
@testset "Tensor space conversions" begin
550+
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), Chebyshev()*Legendre())
551+
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), Chebyshev()*NormalizedLegendre())
552+
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), NormalizedChebyshev()*Legendre())
553+
@test ApproxFunBase.hasconversion(Chebyshev()*NormalizedLegendre(), Chebyshev()*Legendre())
554+
@test ApproxFunBase.hasconversion(NormalizedChebyshev()*Legendre(), Chebyshev()*Legendre())
555+
@test ApproxFunBase.hasconversion(NormalizedChebyshev()*NormalizedLegendre(), Chebyshev()*Legendre())
556+
@test ApproxFunBase.hasconversion(Chebyshev()*Legendre(), NormalizedChebyshev()*NormalizedLegendre())
557+
end
548558
end

0 commit comments

Comments
 (0)