.set() method of ITensor

+1 vote
asked Jul 19 by usuk360 (190 points)

After construct a tenstor with


how can I set a single element without calling

     tensor.set(indval_1, indval_2, ...)

The reason is that std::vector is determined in run time, so I have no idea of how many arguments need to passing into .set function.

1 Answer

0 votes
answered Aug 1 by miles (16,570 points)
selected Aug 2 by usuk360
Best answer

Hi, I just pushed a new commit that adds this feature to ITensor. Now for both the ITensor and IQTensor class you can do this:

auto T = ITensor(i,j);
auto v = vector<IndexVal>{{i(2),j(3)}};

Let me know if it doesn't work as expected or if you run into any issues. I'm planning to add a similar feature for the .real and .cplx methods for retrieving values.

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.