diff --git a/src/tensors/abstracttensor.jl b/src/tensors/abstracttensor.jl index 839b260bf..330092aff 100644 --- a/src/tensors/abstracttensor.jl +++ b/src/tensors/abstracttensor.jl @@ -308,6 +308,15 @@ function adjointtensorindices(t, p::Index2Tuple) return (adjointtensorindices(t, p[1]), adjointtensorindices(t, p[2])) end +""" + isdual(x::AbstractTensorMap) -> Vector{Bool} + +Returns a Boolean vector indicating which spaces of `x` are dual spaces. +""" +function isdual(x::AbstractTensorMap) + return [isdual(space(x, i)) for i in 1:numind(x)] +end + # tensor characteristics: work on instances and pass to type #------------------------------------------------------------ InnerProductStyle(t::AbstractTensorMap) = InnerProductStyle(typeof(t)) diff --git a/test/tensors/construction.jl b/test/tensors/construction.jl index c6047b8d8..2c08b4596 100644 --- a/test/tensors/construction.jl +++ b/test/tensors/construction.jl @@ -24,6 +24,7 @@ for V in spacelist @test space(t) == (W ← one(W)) @test domain(t) == one(W) @test typeof(t) == TensorMap{T, spacetype(t), 5, 0, Vector{T}} + @constinferred isdual(t) # Array type input t = @constinferred zeros(Vector{T}, W) @test @constinferred(hash(t)) == hash(deepcopy(t))