Jutho/TensorKit.jl

fuse tensor legs?

tangwei94 opened this issue · 3 comments

Currently there is no obvious way to fuse the tensor legs for the TensorMap or Tensor object.
It would be ideal if there is a built-in function for this functionality.
As an example, for the TensorMap object A

A = TensorMap(rand, ComplexF64, ℂ^2*^2*^2, ℂ^4)

where A is a TensorMap((ℂ^2 ⊗ ℂ^2 ⊗ ℂ^2) ← ProductSpace(ℂ^4)).
One might expect something like:

A_fused = fuse(A, (1,2))

so that A_fused is a TensorMap((ℂ^4 ⊗ ℂ^2) ← ProductSpace(ℂ^4)).

Jutho commented

I guess the open questions regarding the interface are:

  1. When specifying which indices to fuse, do we only accept a list of consecutive numbers, so that no permutations are necessary?

  2. What do we do if the list of indices stretches over the codomain and domain? Should this be disallowed? If it is allowed, the problem is that you cannot fuse index N1 with index N1+1 without permutations, however, you can fuse indices (..., N1-1, N1, N2, N2-1, ...) without permutations. Also, the question is where we put the resulting fused index, namely in the domain or in the codomain?

  3. In many cases where traditional TN algorithms would tell you to fuse indices, it is not necessary, just because things like svd etc work without explicitly fusing indices. Should we make it clear that there is a significant chance that you don't need this function?

What I was thinking is to only accept consecutive numbers, and the permutations can be done by permute beforehand. For this reason the indices stretching over codomain and domains shouldn't be allowed.
Then I think what you said is indeed right; if only consecutive numbers are accepted, it is unnecessary to explicitly fuse the tensor legs.

I will close this issue since this function is not really needed.