+1 vote
asked by (550 points)
edited by

Sometimes we may feel it's not convenient to copy a Tensor object and use it to contract with other Tensor objects since the indexes of Tensor is unique. When I construct a tensor network, I have to set the indexes of these tensors to fit each other.

Tensor class maybe needs such kind a method, setIndex(oldIndex, newIndex) or replaceIndex(oldIndex, newIndex).

1 Answer

+1 vote
answered by (550 points)

In Itensor there is a kind of tensor named delta tensor. We can use this delta tensor to replace or set Index of a Tensor object(http://itensor.org/docs.cgi?page=classes/diag_itensor).

It looks like
auto T = ITensor(a,b,c);
T *= delta(b,f);

Then we obtain T(a,f,c).

commented by (70.1k points)
Thanks for posting this question & answer Ruizhen
commented by (320 points)
Good point! Maybe a pedantic question as these operations might usually not be a bottleneck of the code:
Is the contraction by a delta tensor handled in a special way? As I guess a contraction as usual might be less efficient than just checking compatibility of indices and then substituting them in the ITensor?
commented by (70.1k points)
You definitely make an important point that "inefficient" code is only really so if it dominates a significant portion of the running time. It's always good to keep an eye on sections of code for possible inefficiencies though. So to answer your question: yes delta tensor contraction is handled in a special way. In fact it launches one of 3 different algorithms depending on the case. For the case of a 2-index delta tensor, the code just replaces one index with another without touching any tensor data. The other two cases deal with whether all of the indices of the delta tensor are contracted or just some. Then it calls special sparse-tensor routines for these cases.
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

...