Generalization of the correlation function

Hi everyone,
I am trying to compute the expectation value of a correlation function made up by a string of operators, something like :

If you are including code in your question or comment, please put it in a code block as follows:

        int m=1;
        int n=6;
        for(int l = m; l <= n; ++l)
            auto Sz = op(sites,"Sz",l);
            auto C = psi0(l)*Sz;
            auto ir = commonIndex(psi0(l),psi0(l+1),"Link");
            auto D = dag(prime(prime(psi0(l),"Site"),ir));
                auto E=C*D;
                E *=  dag(prime(prime(psi0(l),"Site"),"Link"));
                println("E = ",E);


I am trying to generalize the following tutorial (ITensor), but I am making some mistake, because E is not a scalar. Any idea on how to fix this ?
Thank you for your time,

Hi Francesco,

You’re not carrying a (contracted) tensor along for each site, like the C*=... in the tutorial. Ignoring the ends there should be something like

\\set up C tensor here
for(int l = m; l < n; ++l){
  C*= psi0(l)*op(sites,"Sz",l);
  C*= dag(prime(psi0(l));

within the loop


Thank you for your answer, now I figured it out and it is working properly !

1 Like