SVD for non-contiguous bipartitions

Hi,

  1. I am looking for SVD for non-contiguous bipartitions of an MPS. However, even before that if I wish to compute entropy for 2:rest bipartition (i.e., 2:1,3,4,5…N), one way to do that is by applying a swap gate that exchanges the sites (1,2)–> (2,1) and then uses the usual SVD along 1:rest. First I constructed the swapped MPS phi from psi. And then used the SVD for phi along 1:rest. When I am trying to do so, it is showing some problem.
    INPUT:
    psi.position(1);
    auto phi=MPS(N);
    phi.ref(1) = psi(2);
    phi.ref(2) = psi(1);

for(int kkk= 3; kkk <= N; ++kkk)
{
phi.ref(kkk) = psi(kkk);
}

phi.ref(1) = phi(1) * delta(dag(sites(2)),sites(1));
phi.ref(2) = phi(2) * delta(dag(sites(1)),sites(2));

auto l1 = leftLinkIndex(phi,1);
auto s1 = siteIndex(phi,1);

auto [UU,S,V] = svd(phi(1),{l1,s1});

OUT PUT:
From line 568, file indexset.cc

In findIndex: more than one Index found, consider using findInds instead

In findIndex: more than one Index found, consider using findInds instead
Aborted (core dumped)

Any input will be highly appreciated.

  1. Also, do you think finding the Schmidt coefficients for non-contiguous bipartitions SWAP operation is the only way out? I tried first constructing the reduced density matrix and then diagonalizing it but even for moderately large system size, I am having memory problems when I am using diagHermitian.

Thanks