Learn to Use ITensor

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


An IndexVal conceptually represents an Index fixed to a specific value.

IndexVal holds both an Index called "index" and an integer "val" representing a particular value the Index can take. The value is 1-indexed and must be in the range [1,m] where m is the size of the Index.

IndexVals are primarily used for getting and setting elements of an ITensor.

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


auto s1 = Index(4);
auto iva = IndexVal(s1,3),
auto ivb = IndexVal(s1,1);
Print(val(iva)); //prints: val(iva) = 3
Print(val(ivb)); //prints: val(ivb) = 1

//Can make an IndexVal by "plugging" an
//integer into an Index
auto ivc = s1=4; // Same as: auto ivc = s1(4);
Print(val(ivc)); //prints: val(ivc) = 4
Print(index(ivc)); //prints: (4|id=490|s1)

Public Data Members

General Methods

Tag Methods

IndexVals have the same tagging/priming functions as Index objects. Tags of the index of the IndexVal are modified, and the val is left unchanged. Please see the Tag Methods section of the Index documentation for more information.

Click to Show Example
  // Create an Index of dimension 2
  auto i = Index(2,"i");

  // Create an IndexVal
  auto iv = i(1);

  auto iva = addTags(iv,"a");

  Print(index(iva) == addTags(i,"a")); //prints: true

Other Operations With IndexVals

This page current as of version 3.0.0

Back to Classes
Back to Main