Learn to Use ITensor

main / classes / itensor


An ITensor is a tensor with named indices (of type Index). The key feature of the ITensor is automatic contraction over all matching indices, similar to Einstein summation.

An ITensor is created with a fixed number of Index objects specifying its indices. Because Index objects carry identifying information, most of the ITensor interface does not depend on the Index order. For example, given an ITensor constructed with indices a and b, calling elt(T,a=2,b=5) and elt(T,b=5,a=2) accesses the same tensor element.

In addition to real-valued storage, ITensors can have other storage types such as complex storage or various sparse storage types.

If an ITensor is constructed with regular indices (Index objects I for which hasQNs(I)==false) then its storage will be dense.

If instead an ITensor is constructed with indices carrying additional quantum number (QN) block structure (Index objects I for which hasQNs(I)==true) then its storage will be block-sparse. (Up through version 2 of ITensor, such ITensors were called IQTensors.)

The ITensor class is defined in the header "itensor/itensor.h"


auto b1 = Index(5);
auto b3 = Index(8);
auto s2 = Index(2,"Site");
auto s3 = Index(2,"Site");

auto phi = ITensor(b1,s2,s3,b3);

phi.set(b1=2,s2=1,s3=2,b3=2, -0.5);
phi.set(b1=3,s2=2,s3=1,b3=6, 1.4);

auto nrm = norm(phi); //save the original norm of phi
phi /= nrm; //division by a scalar
Print(norm(phi)); //prints: 1.0

//The * operator automatically contracts all matching indices.
//The prime(phi,b3) method primes the b3 Index of the second
//ITensor in the product so it is not contracted.

ITensor rho = phi * prime(phi,b3);

Print(order(rho)); //prints 2
Print(hasIndex(rho,b3)); //prints: true
Print(hasIndex(rho,prime(b3))); //prints: true
Print(hasIndex(rho,s2)); //prints: false

Constructors and Accessor Methods

Element Access Methods

ITensor Prime and Tag Methods

ITensors have all of the same tagging and priming methods that are defined for IndexSets.

Note: all of the following functions listed of the form:

.f(TagSet, ...)

.f(TagSet, TagSet, ...)

.f(int, ...)

perform an in-place modification of the ITensor. ... stands for optional arguments to specify a subset of indices of the ITensor to apply the operation .f().

Functions of the form:

f(ITensor, TagSet, ...) -> ITensor

f(ITensor, TagSet, TagSet, ...) -> ITensor

f(ITensor, int, ...) -> ITensor

perform the same operation as the above in-place operations and accept the same optional arguments, but do not modify the input ITensor and instead return a new, modified ITensor.

Operators Supported By ITensors

In this section, expressions like ITensor * ITensor -> ITensor are pseudocode indicating that two ITensors can be multiplied using the * operator, and that the result will be an ITensor.

Complex ITensor Methods

Elementwise Transformation Methods

Other Facts About ITensors

Functions for Modifying ITensors

Functions for Transforming ITensors

Extracting Properties of ITensors

Analyzing ITensor Indices

Other Functions

Advanced / Developer Methods

This page current as of version 3.0.0

Back to Classes
Back to Main