# complexities of delta Tensor multiplication and the / operation

0 votes
asked

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 (7.3k 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:

https://github.com/ITensor/ITensor/blob/v3/itensor/itdata/diag.cc#L160

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.

-Matt