0 votes
asked by (760 points)

I have two questions about the computational complexity.
1. For a given tensor T,

auto i1 = Index (2);
auto i2 = Index (2);
auto i3 = Index (2);
auto T = randomITensor (i1,i2);

what is the computational complexities of the delta multiplication

T *= delta (i1,i3);

and how does it compare to the replaceInds?

T.replaceInds ({i2},{i3});

Which one is more efficient?

  1. Given two tensors with a common Index

    auto T1 = randomITensor (i1,i2);
    auto T2 = randomITensor (i1,i3);

What is the complexity for the / operation?

auto T3 = T1/T2;

And how does it compare with the delta multiplication?

auto T1 = randomITensor (i1,i2);
auto T2 = randomITensor (i3,i4);
auto T3 = delta(i5,i2,i3) * T1 * T2;

1 Answer

+1 vote
answered by (14.1k points)

Hi Chia-Min,

T.replaceInds(...) and delta should both essentially be no-ops (they should just be replacing the indices in the IndexSet, and not doing anything to the storage). T.replaceInds(...) actually calls delta internally. You can see the code path for that in the contract function here:


If you see that it is taking up more time than expected, please let us know.

The / operation should have a lower complexity, since the delta contraction you show involves making the intermediate tensor delta(...) * T1 which will result in a dense tensor with 4 indices. There are a few things we could try to improve the second example you show, for example return a sparse result for the intermediate, or make contraction into a lazy operation so that both contractions could be "fused" together and something like / (if that is considered best) would be called.


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.