diff --git a/src/spaces/homspace.jl b/src/spaces/homspace.jl index 9ef8a5d51..f1819572e 100644 --- a/src/spaces/homspace.jl +++ b/src/spaces/homspace.jl @@ -56,10 +56,15 @@ const TensorMapSpace{S <: ElementarySpace, N₁, N₂} = HomSpace{ numout(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₁ numin(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₂ +Base.length(W::HomSpace) = numout(W) + numin(W) function Base.getindex(W::TensorMapSpace{<:IndexSpace, N₁, N₂}, i) where {N₁, N₂} return i <= N₁ ? codomain(W)[i] : dual(domain(W)[i - N₁]) end +Base.Broadcast.broadcastable(W::HomSpace) = + TupleTools.vcat(identity.(codomain(W)), dual.(domain(W))) +Base.map(f, W::HomSpace) = f.(W) + function ←(codom::ProductSpace{S}, dom::ProductSpace{S}) where {S <: ElementarySpace} return HomSpace(codom, dom) end diff --git a/test/symmetries/spaces.jl b/test/symmetries/spaces.jl index 0438a7e14..6296bc335 100644 --- a/test/symmetries/spaces.jl +++ b/test/symmetries/spaces.jl @@ -444,6 +444,8 @@ end @test W[3] == V5 @test W[4] == V4 @test W[5] == V3 + @test all(W .== (V1, V2, V5, V4, V3)) + @test @constinferred(map(isdual, W)) == ntuple(i -> isdual(W[i]), length(W)) @test @constinferred(hash(W)) == hash(deepcopy(W)) != hash(W') @test W == deepcopy(W) cod = codomain(W)