Learn to Use ITensor

main / classes / itensor C++v3 | C++v2


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 T.real(a(2),b(5)) and T.real(b(5),a(2)) accesses the same tensor element.

In addition to the default dense real storage, ITensors can have other storage types such as complex storage or various sparse storage types.

The type ITensor is defined in the header "itensor/itensor.h"; also see "itensor/itensor_interface.h" and "itensor/itensor_interface_impl.h".


auto b1 = Index("bond 1",5);
auto b3 = Index("bond 3",8);
auto s2 = Index("site 2",2,Site);
auto s3 = Index("site 3",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(rank(rho)); //prints 2
Print(hasindex(rho,b3)); //prints: true
Print(hasindex(rho,prime(b3))); //prints: true
Print(hasindex(rho,b2)); //prints: false

Constructors and Accessor Methods

Element Access Methods

Prime Level Methods

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 Creating ITensors

Functions for Modifying ITensors

Functions for Transforming ITensors

ITensor Prime Level Transformations

For the following functions, the symbol ... is pseudocode which signifies these functions forward their arguments internally to the ITensor class method with the same name.

See the ITensor prime level methods for details about the possible arguments to these functions.

Extracting Properties of ITensors

Analyzing ITensor Indices

Other Functions

Advanced / Developer Methods

This page current as of version 2.1.1

Back to Classes
Back to Main