eltC function generates wrong answer when calculating inner product

,

Hello,
I wonder why the eltC function and the innerC function generate the different results of the norm of the wave function.

      tJ sitesold;
      readFromFile("sites_file",sitesold);
      MPS psi(sitesold);
      readFromFile("psi_file",psi);
      psi.position(1);
      auto newdagpsi = dag(psi);
      auto Ctest = psi(1)*newdagpsi(1);
      for (int k=2 ;k<=Nx*Ny;k++)
      {
          Ctest *= psi(k);
          Ctest *= newdagpsi(k);
      }
      std::cout<<"testphi0"<<eltC(Ctest)<<std::endl;//result:testphi0(1.73505e+83,-8.44144e+65)
      std::cout<<"testphi0"<<innerC(psi,psi)<<std::endl; //result:testphi0(1,-1.484e-17)

The result generated by the eltC function is exponentially large, I do not know the reason. If you know why, please tell me, thank you very much!

It looks like you need to prime the link indices of either psi or newdagpsi to make sure the link indices in the bra and ket don’t contract with each other.

1 Like

Hi mtfishman,
Thanks a lot! I have fixed the problem.
This code was adapted from the code sample in “Operator Matrix Elements Involving Two MPS” in the code formulas, where the link indices of dag(phi) are not primed since we are measuring the correlation function between two different state |\phi\rangle and |\psi\rangle. In this example, prime the link indices of either psi or newdagpsi are important since they are the same state.
Best regards,
StrongCC