Learn to Use ITensor

main / classes / diag_itensor

Delta and Diagonal ITensor

A diagonal ITensor is an ITensor with diagonal-sparse storage such that only its diagonal elements Tiii... are non-zero. (Diagonal elements mean elements obtained by setting each Index to the same value.)

Uses of diagonal ITensors include replacing one Index of an ITensor with another; tracing pairs of indices; and "tying" multiple indices into a single Index.

Diagonal ITensors can be constructed either by calling the delta or diagITensor functions:

The functions delta and diagITensor are defined in "itensor/itensor.h"; also see "itensor/itensor_impl.h".


auto i = Index(2,"i");
auto j = Index(2,"j");
auto k = Index(2,"k");
auto l = Index(2,"l");

// Replace T's i Index with another Index l
auto T1 = randomITensor(i,j,k);
T1 *= delta(i,l);

// Trace (sum over) a pair of indices
auto T2 = randomITensor(i,j,prime(i));
T2 *= delta(i,prime(i));

// Tie multiple indices together
auto T3 = randomITensor(i,prime(i),j,prime(i,2));
T3 *= delta(i,prime(i),prime(i,2),prime(i,3));


This page current as of version 3.0.0

Back to Classes
Back to Main