Learn to Use ITensor

main / classes / combiner

Combiner ITensor

A combiner is a type of ITensor used to "reshape" several indices into one Index whose size is the product of the smaller indices. The same combiner can be used to reverse this process.

To construct a combiner ITensor, call the combiner method with the indices you want to combine as arguments.

To retrieve the "combined" index that results from merging all of the indices provided, use the combinedIndex` function (see below).

Internally, a combiner is implemented as a type of ITensor with a special storage type. This storage performs no allocation of any elements whatsoever; when a combiner ITensor is contracted with another ITensor, special optimized routines are called to reshape the regular ITensor into the resulting ITensor with combined indices as efficiently as possible.


auto i = Index(3);
auto j = Index(5);
auto k = Index(7);
auto l = Index(9);

auto T = randomITensor(i,j,k,l);

auto [C,c] = combiner(i,k);

// Combine
auto cT = C * T; //or T * C, which has same effect

Print(hasindex(cT,i)); //prints: false
Print(hasindex(cT,j)); //prints: true
Print(hasindex(cT,k)); //prints: false
Print(hasindex(cT,l)); //prints: true
Print(hasindex(cT,c)); //prints: true

Print(order(cT)); //prints: 3

Print(c == commonIndex(C,cT)); //prints: true

Print(dim(c)); //prints 21 = 7*3

// Uncombine
auto nT = cT * C;

//Check that nT == T
Print(norm(nT-T)); //prints: 0.0


Related functions

This page current as of version 3.0.0

Back to Classes
Back to Main