Skip to content

Commit 4401c9f

Browse files
committed
add support for broadcasting/mapping over HomSpace
1 parent 88fe4ef commit 4401c9f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/spaces/homspace.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ const TensorMapSpace{S <: ElementarySpace, N₁, N₂} = HomSpace{
5656
numout(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₁
5757
numin(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₂
5858

59+
Base.length(W::HomSpace) = numout(W) + numin(W)
5960
function Base.getindex(W::TensorMapSpace{<:IndexSpace, N₁, N₂}, i) where {N₁, N₂}
6061
return i <= N₁ ? codomain(W)[i] : dual(domain(W)[i - N₁])
6162
end
6263

64+
Base.Broadcast.broadcastable(W::HomSpace) =
65+
TupleTools.vcat(identity.(codomain(W)), dual.(domain(W)))
66+
Base.map(f, W::HomSpace) = f.(W)
67+
6368
function (codom::ProductSpace{S}, dom::ProductSpace{S}) where {S <: ElementarySpace}
6469
return HomSpace(codom, dom)
6570
end

0 commit comments

Comments
 (0)