# .set() method of ITensor

+1 vote

After construct a tenstor with

    ITensor(std::vector<Index>)


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.

answered Aug 1 by (18,230 points)
selected Aug 2 by usuk360

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)}};
T.set(v,3.1415);


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.