BTW, unexpectedly, I find this implementation is much slower than the naive one (i.e., using OpSum to make an MPO for each i,j)
Here is my code for calculate the fermion 2pt correlator using this MPS techniques:
```
begin
orthogonalize!(psi,1)
corr1 = zeros(div(N,3),div(N,3))
L = ITensor(1.)
for i=1:N
if mod(i,3)==0
Li = L*psi[i]*op("Cdag",sites,i)*dag(prime(psi[i]))
LiF = Li
for j=i+3:3:N
LiF *= psi[j-2]*op("F",sites,j-2)*dag(prime(psi[j-2]))
LiF *= psi[j-1]*dag(prime(psi[j-1],"Link"))
lind = commonind(psi[j],LiF)
LiF *= psi[j]
cij = LiF*op("C",sites,j)*dag(prime(prime(psi[j],"Site"),lind))
corr1[div(i,3),div(j,3)] = scalar(cij)
corr1[div(j,3),div(i,3)] = conj(corr1[div(i,3),div(j,3)])
LiF *= op("F",sites,j)*dag(prime(psi[j]))
end
end
L *= psi[i]*dag(prime(psi[i],"Link"))
end
# fill in diagonal elements
for i=1:div(N,3)
orthogonalize!(psi,3*i)
corr1[i,i] = scalar(psi[3i]*op("N",sites,3*i)*dag(prime(psi[3i],"Site")))
end
end
```
Note the sites are defined as follows (basically a fermion ladder with dynamical Z2 gauge fields is deformed into a fermion-spin-fermion chain):
```
sites = [ isodd(mod1(n,3)) ? siteind("Fermion",n,conserve_qns=true) : Index([QN()=>2];tags="S=1/2,Site,n=$n") for n in 1:N]
```
Why this method is much slower than a naive MPO construction from OpSum?