Skip to content

Commit 8d5ee81

Browse files
authored
Function barrier in PiecewiseSpace (#200)
* function barrier in `PiecewiseSpace` * Add test * improve `promotespaces` performance * version bump to v0.7.1
1 parent 1561361 commit 8d5ee81

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
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.7.0"
3+
version = "0.7.1"
44

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

src/ApproxFunBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ end
105105
# assert that the conversion succeeds. This helps with inference as well as sanity
106106
strictconvert(T::Type, x) = convert(T, x)::T
107107

108+
uniontypedvec(A, B) = Union{typeof(A), typeof(B)}[A, B]
109+
108110
include("LinearAlgebra/LinearAlgebra.jl")
109111
include("Fun.jl")
110112
include("onehotvector.jl")

src/Operators/spacepromotion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function promotespaces(A::Operator,B::Operator)
156156
if spacescompatible(A,B)
157157
A,B
158158
else
159-
tuple(promotespaces([A,B])...)
159+
tuple(Vec{2}(promotespaces(uniontypedvec(A,B)))...)
160160
end
161161
end
162162

src/Spaces/SumSpace.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ struct PiecewiseSpace{SV,D<:UnionDomain,R} <: DirectSumSpace{SV,D,R}
6161
new{SV,D,R}(sp)
6262
end
6363

64-
function PiecewiseSpace(spin::Tuple)
65-
sp=tuple(union(spin)...) # remove duplicates
66-
64+
function _PiecewiseSpace(sp)
6765
PiecewiseSpace{typeof(sp),typeof(UnionDomain(map(domain,sp))),
6866
mapreduce(rangetype,promote_type,sp)}(sp)
6967
end
68+
function PiecewiseSpace(spin::Tuple)
69+
sp=tuple(union(spin)...) # remove duplicates
70+
_PiecewiseSpace(sp)
71+
end
7072

7173
PiecewiseSpace(spin::Set) = PiecewiseSpace(collect(spin))
7274

test/SpacesTest.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ using LinearAlgebra
140140
@test CM == Diagonal(1:3)
141141
@test size(C[1:0, 1:0]) == (0, 0)
142142
end
143+
144+
@testset "broadcast" begin
145+
f = Fun(PointSpace(1:3), 1:3)
146+
g = f^2
147+
h = f.^2
148+
for i in 1:3
149+
@test g(i) == h(i)
150+
end
151+
end
143152
end
144153

145154
@testset "DiracSpace" begin

0 commit comments

Comments
 (0)