Skip to content

Commit

Permalink
isconvertible returns true for same space, union of Fourier and Cheby…
Browse files Browse the repository at this point in the history
…shev gives a Chebyshev (#602)
  • Loading branch information
dlfivefifty committed Aug 22, 2018
1 parent e4ac31a commit e8289c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Fun/Space.jl
Expand Up @@ -291,7 +291,7 @@ hasconversion(a,b) = maxspace(a,b) == b


# tests whether a coefficients can be converted to b
isconvertible(a,b) = hasconversion(a,b)
isconvertible(a,b) = a == b || hasconversion(a,b)

## Conversion routines
# coefficients(v::AbstractVector,a,b)
Expand Down
5 changes: 4 additions & 1 deletion src/Spaces/Modifier/SumSpace.jl
Expand Up @@ -270,7 +270,7 @@ function union_rule(B::ConstantSpace,A::SumSpace)
end
end

function union_rule(A::SumSpace,B::Space)
function union_rule(A::SumSpace, B::Space)
if !domainscompatible(A,B)
NoSpace()
else
Expand All @@ -283,6 +283,9 @@ function union_rule(A::SumSpace,B::Space)
end
end

union_rule(A::SumSpace{<:Any,<:PeriodicInterval}, B::Space{<:IntervalDomain}) =
union(Space(Interval(domain(A))), B)


## components

Expand Down
2 changes: 2 additions & 0 deletions src/Spaces/PeriodicSpace.jl
Expand Up @@ -14,3 +14,5 @@ DefiniteIntegral(d::PeriodicDomain) = DefiniteIntegral(Laurent(d))
DefiniteLineIntegral(d::PeriodicDomain) = DefiniteLineIntegral(Laurent(d))

## Toeplitz
union_rule(A::Space{<:PeriodicInterval}, B::Space{<:IntervalDomain}) =
union(Space(Interval(domain(A))), B)
19 changes: 17 additions & 2 deletions test/SpacesTest.jl
Expand Up @@ -329,13 +329,11 @@ using ApproxFun, SpecialFunctions, LinearAlgebra, Test
@test o(0.5) == 1
end


@testset "blockbandinds for FiniteOperator of pointscompatibleace bug" begin
S = ApproxFun.PointSpace([1.0,2.0])
@test ApproxFun.blockbandinds(FiniteOperator([1 2; 3 4],S,S)) == (0,0)
end

#SumSpace Conversion
@testset "SumSpace Conversion" begin
H = ApproxFun.HeavisideSpace([-1.0,0.0,1.0])
C = ApproxFun.ContinuousSpace(ApproxFun.PiecewiseSegment([-1.0,0,1]))
Expand All @@ -354,4 +352,21 @@ using ApproxFun, SpecialFunctions, LinearAlgebra, Test
f = Fun(S, randn(100))
@test (Conversion(S,S2) * f)(0.1) f(0.1)
end

@testset "Mix Fourier-Chebyshev (#602)" begin
s = Chebyshev(-π..π)
a = Fun(t-> 1+sin(cos(2t)), s)
L = Derivative() + a
f = Fun(t->exp(sin(10t)), s)
B = periodic(s,0)
uChebyshev = [B;L] \ [0.;f]

s = Fourier(-π..π)
a = Fun(t-> 1+sin(cos(2t)), s)
L = Derivative() + a
f = Fun(t->exp(sin(10t)), s)
uFourier = L\f

@test norm(uFourier-uChebyshev)  100eps()
end
end

0 comments on commit e8289c7

Please sign in to comment.