Learn to Use ITensor

main / classes / iqtensor


An IQTensor is similar to an ITensor in that it has named indices and supports most of the same operations. But an IQTensor also has a block sparse structure related to conservation of Abelian "quantum numbers". IQTensors actually have the same interface as ITensors, but the indices of an IQTensor are of type IQIndex.

IQTensors obey the rule that the only blocks allowed to be non-zero are those with the same QN "divergence". A block of an IQTensor corresponds to a specific sector of each IQIndex. The divergence of a given block is the sum of the QNs of the corresponding sectors times the Arrow direction of each IQIndex. On an intuitive level, the divergence of an IQTensor says how much the total quantum number will be changed by contracting with that IQTensor. As an example involving spins, an "Sz" operator has zero divergence while an "S+" operator has divergence +2 since it increases the total Sz by +2 (in units of spin 1/2).

Contracting IQTensors can be much more efficient than contracting ITensors. This is because IQTensors have an explicit sparse structure where many of its blocks are constrained to be zero.

Because IQTensor and ITensor have an identical interface (both implemented using the same template class), to see a list of class methods available for IQTensors see the ITensor documentation.

Functions acting on ITensors which are not discussed below can be assumed to have the same behavior for IQTensors.

IQTensor is defined in "itensor/iqtensor.h"; also see "itensor/iqtensor.ih". The IQTensor interface is defined in "itensor/itensor_interface.h".


auto L = IQIndex("L",Index("L-",2),QN(-1),
                     Index("L0",4),QN( 0),
auto S = IQIndex("S",Index("S-",1),QN(-1),

//Create a zero IQTensor
auto A = IQTensor(L,S);

//Setting an element determines
//the divergence of this IQTensor

//Compute IQTensor divergence
Print(div(A)); //prints: QN(0)

//Create an IQTensor with div QN(0)
//but otherwise random elements
auto B = randomTensor(QN(0),dag(L),S);

//Contracting IQTensors is very similar to 
//contracting ITensors except contracted 
//IQIndex's must have opposite Arrow directions
auto R = A * B; //contract over common IQIndex L

IQTensor Class Methods Specializations

Operations on IQTensors

Most operation available for ITensors work similarly for IQTensors. The following are operations which have different behavior or are only defined for IQTensors:

Functions for Constructing IQTensors

Functions for Constructing Sparse IQTensors

Functions for Analyzing IQTensors

Developer / Advanced Methods

This page current as of version 2.0.6

Back to Classes
Back to Main