+1 vote
asked by (170 points)

I tried to run the sample code for TRG provided on the ITensor homepage (https://itensor.org/docs.cgi?page=book/trg&vers=cppv3) to familiarize myself with ITensor. I followed the instructions, cloned the latest version of ITensor with git, successfully installed it and tried to compile the code. However, I received the following error message:
trg.cc: In function ‘int main()’:
trg.cc:47:12: error: 3 names provided while ‘std::tuple<itensor::ITensor, itensor::ITensor>’ decomposes into 2 elements
auto [Fl,Fr,lnew] = factor(A,{r,d},{l,u},{"MaxDim=",maxdim,
^~~~~~~~~~~~~
trg.cc:52:12: error: 3 names provided while ‘std::tuple<itensor::ITensor, itensor::ITensor>’ decomposes into 2 elements
auto [Fu,Fd,u
new] = factor(A,{l,d},{u,r},{"MaxDim=",maxdim,

Looking into the documentation, factor should behave as

factor(ITensor T, IndexSet Ais[, IndexSet Bis],
       Args args = Args::global()) -> std::tuple<ITensor,ITensor>

Indeed, if I replace the the call to factor with

auto [Fl,Fr] = factor(A,{r,d},{l,u},{"MaxDim=",maxdim,
                                     "Tags=","left,scale="+str(scale),
                                     "ShowEigs=",true});
auto l_new = commonIndex(Fl,Fr);

and correspondingly the second call for factoring A in Fu, Fd , everything seems to work fine.

I was just wondering if I overlooked something, or if the calls to factor in the example provided should be replaced as shown above?

commented by (70.1k points)
Thanks for catching this & for the bug report. Just updated the website as Matt suggested to make this change.
commented by (170 points)
Thanks Matt, thanks Miles.
Just one more thing I stumbled across on the website: isn't there a @@ -2\beta @@ too much in the formula for @@ \ln(Z)/N_s @@? Since @@ \ln(Z)/N_s @@ should be   @@ -\beta F @@ with  @@ F @@ the free energy density, this should go as shown here: https://en.wikipedia.org/wiki/Square-lattice_Ising_model#Exact_solution
Indeed, if I remove the @@ -2\beta @@ from the formula and compare the output of ITensor for various temperatures, it matches nicely.
commented by (70.1k points)
Thanks for noticing this. I don't recall why I added that term to the solution, but I checked and you're right that the TRG code agrees only when it's removed. So I just made that change to the website!

1 Answer

+1 vote
answered by (14.1k points)
selected by
 
Best answer

Thank you for catching that, that needs to be fixed in the way that you show.

The correct code can be found in the "sample" directory of the ITensor library (https://github.com/ITensor/ITensor/blob/v3/sample/trg.cc ), we forgot to update the website with the proper code.

Cheers,
Matt

commented by (70.1k points)
Ok just fixed this on the website!
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...