Hello,

how we can calculate the entanglement entropy of an half chain with Julia?

I am trying to adapt the following lines of code which are given for C++

Thanks a lot!

Jacopo

auto b = 10;

//"Gauge" the MPS to site b

psi.position(b);

//SVD this wavefunction to get the spectrum

//of density-matrix eigenvalues

auto l = leftLinkIndex(psi,b);

auto s = siteIndex(psi,b);

auto [U,S,V] = svd(psi(b),{l,s});

auto u = commonIndex(U,S);

//Apply von Neumann formula

//to the squares of the singular values

Real SvN = 0.;

for(auto n : range1(dim(u)))

{

auto Sn = elt(S,n,n);

auto p = sqr(Sn);

if(p > 1E-12) SvN += -p*log(p);

}