Learn to Use ITensor

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

ITensor version 3 has not been released yet. This documentation is a preview only.

Index

An Index represents a single tensor index with fixed dimension. Copies of an Index compare equal unless their prime levels and tags are set to different values.

An Index carries a TagSet, a set of tags which are small strings that specify properties of the Index to help distinguish it from other Indices.

Internally, an Index has a fixed id number, which is how the ITensor library knows two indices are copies of a single original Index. Index objects must have the same id, as well as the same prime level and tags to compare equal.

Index is defined in "itensor/index.h".

Synopsis

auto i = Index(4);
Print(dim(i)); //prints: dim(i) = 4

//Copies of the same Index compare equal
auto ii = i; //ii is a copy of i
Print(ii == i); //prints: true

//The prime level of an Index can be
//adjusted to make it distinct
ii.prime(2);
Print(primeLevel(ii)); //prints: primeLevel(ii) = 2
Print(ii == i); //prints: false

ii.noPrime();
Print(ii == i); //prints: true

// Index objects can also hold a set of up to four tags
auto j = Index(5,"j,Link");
Print(hasTags(j,"j")); //prints: true

// Tags can be added to or removed from an index
// Indices must have the same tags to compare equal
auto ia = addTags(i,"a");
Print(ia == i); //prints: false

Print(removeTags(ia,"a") == i); //prints: true

auto iab = addTags(ia,"b");

Print(tags(i)); //prints: ""
Print(tags(ia)); //prints: "a"
Print(tags(iab)); //prints: "a,b"

Print(hasTags(iab,"b,a")); //prints: true

Constructors

Accessor Methods

Prime Level Functions

Tag functions

Operators and Conversions

Other Index Class Methods

Other Functions


This page current as of version 3.0.0


Back to Classes
Back to Main