@@ -89,70 +89,74 @@ domain(t::AbstractTensorMap) = domain(space(t))
8989domain (t:: AbstractTensorMap , i) = domain (t)[i]
9090source (t:: AbstractTensorMap ) = domain (t) # categorical terminology
9191
92- """
93- numout(::Union{TT,Type{TT}}) where {TT<:AbstractTensorMap} -> Int
92+ @doc """
93+ numout(x) -> Int
94+ numout(T::Type) -> Int
9495
95- Return the number of output spaces of a tensor. This is equivalent to the number of spaces in the codomain of that tensor.
96+ Return the length of the codomain, i.e. the number of output spaces.
97+ By default, this is implemented in the type domain.
9698
9799See also [`numin`](@ref) and [`numind`](@ref).
98- """
100+ """ numout
101+
102+ numout (x) = numout (typeof (x))
103+ numout (T:: Type ) = throw (MethodError (numout, T)) # avoid infinite recursion
99104numout (:: Type{<:AbstractTensorMap{T, S, N₁}} ) where {T, S, N₁} = N₁
100105
101- """
102- numin(::Union{TT,Type{TT}}) where {TT<:AbstractTensorMap} -> Int
106+ @doc """
107+ numin(x) -> Int
108+ numin(T::Type) -> Int
103109
104- Return the number of input spaces of a tensor. This is equivalent to the number of spaces in the domain of that tensor.
110+ Return the length of the domain, i.e. the number of input spaces.
111+ By default, this is implemented in the type domain.
105112
106113See also [`numout`](@ref) and [`numind`](@ref).
107- """
114+ """ numin
115+
116+ numin (x) = numin (typeof (x))
117+ numin (T:: Type ) = throw (MethodError (numin, T)) # avoid infinite recursion
108118numin (:: Type{<:AbstractTensorMap{T, S, N₁, N₂}} ) where {T, S, N₁, N₂} = N₂
109119
110120"""
111- numind(::Union{T,Type{T}}) where {T<:AbstractTensorMap} -> Int
121+ numind(x) -> Int
122+ numind(T::Type) -> Int
123+ order(x) = numind(x)
112124
113- Return the total number of input and output spaces of a tensor. This is equivalent to the
114- total number of spaces in the domain and codomain of that tensor .
125+ Return the total number of input and output spaces, i.e. `numin(x) + numout(x)`.
126+ Alternatively, the alias `order` can also be used .
115127
116128See also [`numout`](@ref) and [`numin`](@ref).
117129"""
118- numind (:: Type{TT} ) where {TT <: AbstractTensorMap } = numin (TT) + numout (TT)
130+ numind (x) = numin (x) + numout (x)
131+
119132const order = numind
120133
121134"""
122- codomainind(::Union{TT, Type{TT}}) where {TT <: Union{HomSpace, AbstractTensorMap}} -> Tuple{Int}
135+ codomainind(x) -> Tuple{Int}
123136
124- Return all indices of the codomain of a tensor or tensor space .
137+ Return all indices of the codomain.
125138
126139See also [`domainind`](@ref) and [`allind`](@ref).
127140"""
128- function codomainind (:: Type{TT} ) where {TT <: Union{AbstractTensorMap, HomSpace} }
129- return ntuple (identity, numout (TT))
130- end
131- codomainind (t:: Union{AbstractTensorMap, HomSpace} ) = codomainind (typeof (t))
141+ codomainind (x) = ntuple (identity, numout (x))
132142
133143"""
134- domainind(::Union{TT,Type{TT}}) where {TT<:AbstractTensorMap} -> Tuple{Int}
144+ domainind(x) -> Tuple{Int}
135145
136- Return all indices of the domain of a tensor or tensor space .
146+ Return all indices of the domain.
137147
138148See also [`codomainind`](@ref) and [`allind`](@ref).
139149"""
140- function domainind (:: Type{TT} ) where {TT <: Union{HomSpace, AbstractTensorMap} }
141- return ntuple (n -> numout (TT) + n, numin (TT))
142- end
143- domainind (t:: Union{AbstractTensorMap, HomSpace} ) = domainind (typeof (t))
150+ domainind (x) = ntuple (n -> numout (x) + n, numin (x))
144151
145152"""
146- allind(::Union{TT,Type{TT}}) where {TT<:AbstractTensorMap} -> Tuple{Int}
153+ allind(x) -> Tuple{Int}
147154
148- Return all indices of a tensor or tensor space , i.e. the indices of its domain and codomain.
155+ Return all indices, i.e. the indices of both domain and codomain.
149156
150157See also [`codomainind`](@ref) and [`domainind`](@ref).
151158"""
152- function allind (:: Type{TT} ) where {TT <: Union{HomSpace, AbstractTensorMap} }
153- return ntuple (identity, numind (TT))
154- end
155- allind (t:: Union{HomSpace, AbstractTensorMap} ) = allind (typeof (t))
159+ allind (x) = ntuple (identity, numind (x))
156160
157161function adjointtensorindex (t, i)
158162 return ifelse (i <= numout (t), numin (t) + i, i - numout (t))
0 commit comments