Jutho/TensorKit.jl

`fuse` inconsistent in handling dual spaces

Closed this issue · 2 comments

Encountered the folowing inconsistent/inconvenient behaviour for fusing vector spaces: fuse(a, b...) automatically results in a non-dual vectorspace, while fuse(a) simply returns a. I think it might be more convenient to ensure that fuse either always returns a non-dual space, or has a keyword to switch between the outputs.

julia> using TensorKit

julia> a = U1Space(1 => 1)
Rep[U₁](1=>1)

julia> fuse(a * a)
Rep[U₁](2=>1)

julia> fuse(a)
Rep[U₁](1=>1)

julia> fuse(a')
Rep[U₁](1=>1)'

julia> fuse(a' * a)
Rep[U₁](0=>1)

In my particular case, I am iteratively fusing more and more spaces together to determine the maximal virtual spaces of an MPS, and now have to insert a weird special case to catch when a single dual space is being entered.

replacing
fuse(V::ElementarySpace) = V
on line 155 in vectorspaces.jl with
fuse(V::ElementarySpace) = isdual(V) ? flip(V) : V
will fix this, I believe. Should I add this?

I would like this, yes please ☺️