Hi, sorry if this question is a bit naive. I want to implement a sweeping type algorithm, and I want to utilize as much of ITensor's capabilities to enhance efficiency. What I need to do is calculate the matrix elements
(psidag| S_i^z |in)
for all i in the lattice. The calculation is at finite T, so I have an ancilla that I don't need matrix elements on. What I currently do is create all sets of tensors to the left and right by
L[1] = ( psidag(P[1])*in(P[1]) ) * ( psidag(A[1]) * in(A[1]) );
R[N] = psidag(A[N])*in(A[N]);
for(auto i : range1(2,N))
{
auto I = N-i+1;
L[i] = L[i-1] * ( ( psidag(P[i])*in(P[i]) ) * ( psidag(A[i]) *in(A[i]) ) );
R[I] = R[I+1] * ( ( psidag(P[I+1])*in(P[I+1]) ) * ( psidag(A[I]) *in(A[I]) ) );
}
Where P[i] is the ith physical site, and A[i] is the ith ancilla site, they are consecutive (p[1] = 1, A[1]=2, P[2] = 3, A[2] =4, etc.). Then, the ith matrix element is
auto res = L[i-1] * psidag(P[i]) * noPrime(in(P[i]) * op(sites,"Sz",P[i])) * R[i];
Now, my question is if there is a better way to do this with ITensor? I have noticed it's quite inefficient with increased bond dimensions. My initial thought was that this is better than just using 'inner', as I'm saving the majority of the tensor contraction from one value of i to the next. Space complexity is not a major factor for me, but time is.