IQIndex
(subclass of Index)
An IQIndex is a tensor index with additional structure. As a subtype of Index, an IQIndex has a name, size, type, prime level, and unique id number. IQIndex also inherits all of the class methods of Index.
An IQIndex is also divided into quantum number "blocks". Each block is defined by a Index-QN pair (an IndexQN) where the size of each block is the size of its Index. The size of an IQIndex is the total size of all of its blocks. The order and number of blocks of an IQIndex cannot be changed after the IQIndex is constructed.
For example, the IQIndex representing a single spin 1/2 has total size 2, which is made up of two blocks:
- a spin up block of size 1, indicated by a QN(+1) paired with an Index of size 1
- a spin down block of size 1, indicated by a QN(-1) paired with an Index of size 1
An IQIndex also has a direction, which is of type Arrow. An Arrow can be In or Out,
and the default for an IQIndex is Out.
For more information on Arrows, see the page on index conventions.
IQIndex is defined in the header "itensor/iqindex.h".
Synopsis
// Make an IQIndex with five blocks
// and total size 4+8+10+8+4=34
auto I = IQIndex("I",Index("I+2",4),QN(+2),
Index("I+1",8),QN(+1),
Index("I_0",10),QN(0),
Index("I-1",8),QN(-1),
Index("I-2",4),QN(-2));
Print(I.m()); //prints: I.m() = 34
//Get number of blocks of I
Print(I.nblock()); //prints: I.nblock() = 5
//Get Index and QN of block 2
Print(I.index(2)); //prints: (I+1,8,Link)
Print(I.qn(2)); //prints: QN(+1)
//Get direction of I
Print(I.dir()); //prints: I.dir() = Out
Class Methods (only showing those differing from Index)
IQIndex(string name, Index i1, QN q1, Index i2, QN q2, ..., Arrow dir = Out)`
Construct an IQIndex with the given name and blocks corresponding to the Index-QN pairs provided.
Optionally, the last argument can be an Arrow direction, which defaults toOut.Click to Show Exampleauto I = IQIndex("I",Index("I+2",4),QN(+2), Index("I+1",8),QN(+1), Index("I_0",10),QN(0), Index("I-1",8),QN(-1), Index("I-2",4),QN(-2));
IQIndex(std::string name, std::vector<IndexQN> && iq, Arrow dir = Out, int plev = 0)
Construct an IQIndex with the following attributes:
nameis the name of the IQIndexiqis a std::vector<IndexQN> which defines the blocks, in order, of the IQIndex.iqis an rvalue and its contents will be moved into the IQIndex.- Optional
dirspecifying the direction of the IQIndex - Optional
plevspecifying the prime level of the IQIndex
For more information on the IndexQN class, click here.
Click to Show Exampleauto v = stdx::reserve_vector<IndexQN>(5); v.emplace_back(Index("I+2",4),QN(+2)); v.emplace_back(Index("I+1",8),QN(+1)); v.emplace_back(Index("I_0",10),QN(0)); v.emplace_back(Index("I-1",8),QN(-1)); v.emplace_back(Index("I-2",4),QN(-2)); auto I = IQIndex("I",std::move(v),Out,0);
.nblock() -> long
.nindex() -> longReturn the number of blocks of this IQIndex.
(.nindex()is just an alternative name for backwards compatibility reasons.).index(int i) -> IndexReturn the Index of the nth block of this IQIndex.
n is 1-indexed..operator[](int n) -> IndexReturn the Index of the nth block of this IQIndex.
n is 0-indexed..qn(int n) -> QNReturn the QN of the nth block of this IQIndex. n is 1-indexed.
.dir() -> ArrowReturn the Arrow direction of this IQIndex. Can be
InorOut.
For more information see the index conventions page..operator()(int n) -> IQIndexValReturn the IQIndexVal representing this IQIndex set to a specific value "n".
For an IQIndexI, n can range from [1,m] where m is the size ofI..dag()Reverse the arrow of this IQIndex.
Other Features of IQIndex
An IQIndex can be compared to another using
==or!=. IQIndex comparison ignores the Arrow direction, thus it works identically to Index comparison, only caring about the prime level and internal id number.An IQIndex supports iteration, for example
for(auto& iq : I) { println(iq.index); println(iq.qn); }
IQIndex iterators are read-only and dereference to IndexQN's.
An IQIndex
Ican be read to and written from disk by callingI.read(s)andI.write(s)wheresis a stream object.
IQIndex Functions
dag(IQIndex I) -> IQIndexReturn a copy of
Iwith its arrow direction reversed.hasindex(IQIndex I, Index j) -> boolReturn
trueif the Indexjlabels one of the blocks of the IQIndexI.findindex(IQIndex I, Index j) -> longReturn the integer
nof the block ofIlabeled by the Indexj.
The returned integer fulfills the propertyI.index(n) == j.
If no block matchingjis found, the return value is0.offset(IQIndex I, Index j) -> longReturn the sum of sizes of all blocks of
Ipreceding the block corresponding toj.For example, if
jlabels the third block, and blocks one and two have sizes 4 and 7, then offset(I,j) returns 4+7=11.qn(IQIndex I, Index j) -> QNReturn the quantum number of the block labeled by
j.
If there is no matching block, throws an exception.findByQN(IQIndex I, QN q) -> IndexReturn the Index labeling the first block whose QN matches q.
If there is no matching block, throws an exception.showm(IQIndex I) -> stringReturn a string with detailed information about the total size and individual block sizes and quantum numbers of the IQIndex.
Prime Level Functions
prime(IQIndex I, int inc = 1) -> IQIndexReturn a copy of
Iwith prime level increased by 1 (or optional amountinc).prime(IQIndex I, IndexType type, int inc = 1) -> IQIndex
Return a copy of
Iwith prime level increased by 1 (orinc) ifI.type()equals specified type.noprime(IQIndex I, IndexType type = All) -> IQIndexReturn a copy of
Iwith prime level set to zero (optionally only ifI.type()matches type).mapprime(IQIndex I, int plevold, int plevnew, IndexType type = All) -> IQIndex
Return a copy of
Iwith prime level plevnew ifI.primeLevel()==plevold. Otherwise has no effect. (Optionally, only map prime level if type ofImatches specified type.)
This page current as of version 2.0.6