`flip(::DiagonalTensorMap, is)` returns `TensorMap`
Currently, flipping the legs of a diagonal tensor loses that the diagonal information:
julia> d = DiagonalTensorMap{Float64}(undef, ℂ^3)
DiagonalTensorMap(ℂ^3 ← ℂ^3):
0.0 ⋅ ⋅
⋅ 6.798626232e-314 ⋅
⋅ ⋅ 0.0
julia> flip(d, 1)
TensorMap((ℂ^3)' ← ℂ^3):
0.0 0.0 0.0
0.0 6.798626232e-314 0.0
0.0 0.0 0.0
Diagonal only exists if domain == codomain, so the problem is that only flip(d, (1,2)) can preserve the DiagonalTensorMap structure.
transpose(d) could be used to flip the domain and codomain, but this might not have the same semantics in terms of preserving contractions.
Oh, that's also true... I think we can work around this in this particular case by doing the svd in the "other direction", but this is definitely a bit of an annoying problem. We could consider checking that flip(d, (1, 2)) contains either zero or both indices, and throw an error to tell the user to explicitly convert to TensorMap if they want a different result, but that also feels very opinionated and clunky...
How about an additional flip!(dst, src, I; inv) method?
Oh, that's also true... I think we can work around this in this particular case by doing the
svdin the "other direction", but this is definitely a bit of an annoying problem. We could consider checking thatflip(d, (1, 2))contains either zero or both indices, and throw an error to tell the user to explicitly convert toTensorMapif they want a different result, but that also feels very opinionated and clunky...
We could also support DiagonalTensorMap with isomorphic domain and codomain; I don't think there is a strong argument for having domain == codomain.
Adding on to this: transpose(::DiagonalTensorMap) without specifying indices can be special-cased to output a DiagonalTensorMap.