@@ -547,17 +547,15 @@ end
547547
548548# similar diagonal
549549# ----------------
550- # The implementation is again written for similar_diagonal(t, TorA, V::TensorSpace ) -> DiagonalTensorMap
550+ # The implementation is again written for similar_diagonal(t, TorA, V::ElementarySpace ) -> DiagonalTensorMap
551551# and all other methods are just filling in default arguments
552552@doc """
553- similar_diagonal(t::AbstractTensorMap, [AorT=storagetype(t)], [V=space(t)])
554- similar_diagonal(t::AbstractTensorMap, [AorT=storagetype(t)], codomain, domain)
553+ similar_diagonal(t::AbstractTensorMap, [AorT=storagetype(t)], [V::ElementarySpace])
555554
556555Creates an uninitialized mutable diagonal tensor with the given scalar or storagetype `AorT` and
557- structure `V` or `codomain ← domain`, based on the source tensormap. The second and third
558- arguments are both optional, defaulting to the given tensor's `storagetype` and `space`.
559- The structure may be specified either as a single `HomSpace` argument or as `codomain` and
560- `domain`.
556+ structure `V ← V`, based on the source tensormap. The second argument is optional and defaults
557+ to the given tensor's `storagetype`, while the third argument can only be omitted for square
558+ input tensors of space `V ← V`, to conform with the diagonal structure.
561559
562560By default, this will result in `DiagonalTensorMap{T}(undef, V)` when custom objects do not
563561specialize this method. Furthermore, the method will throw if the provided space is not compatible
@@ -566,23 +564,7 @@ with a diagonal structure.
566564See also [`Base.similar`](@ref).
567565""" similar_diagonal (:: AbstractTensorMap , args... )
568566
569- # 4 arguments
570- function similar_diagonal (t:: AbstractTensorMap , :: Type{T} , cod:: TensorSpace , dom:: TensorSpace ) where {T}
571- length (cod) == length (dom) == 1 && cod == dom ||
572- throw (ArgumentError (" requested space is not square" ))
573- return similar_diagonal (t, T, cod)
574- end
575-
576567# 3 arguments
577- function similar_diagonal (t:: AbstractTensorMap , :: Type{T} , V:: TensorMapSpace ) where {T}
578- numout (V) == numin (V) == 1 && domain (V) == codomain (V) ||
579- throw (ArgumentError (" requested space is not square" ))
580- return similar_diagonal (t, T, codomain (V))
581- end
582- function similar_diagonal (t:: AbstractTensorMap , :: Type{T} , V:: ProductSpace ) where {T}
583- length (V) == 1 || throw (ArgumentError ())
584- return similar_diagonal (t, T, only (V. spaces))
585- end
586568function similar_diagonal (t:: AbstractTensorMap , :: Type{TorA} , V:: ElementarySpace ) where {TorA}
587569 if TorA <: Number
588570 T = TorA
0 commit comments