Index
Description
ITensors.Index — TypeAn Index represents a single tensor index with fixed dimension dim. Copies of an Index compare equal unless their tags are different.
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. There is a special tag which is referred to as the integer tag or prime level which can be incremented or decremented with special priming functions.
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 tags to compare equal.
ITensors.QNIndex — TypeA QN Index is an Index with QN block storage instead of just an integer dimension. The QN block storage is a vector of pairs of QNs and block dimensions. The total dimension of a QN Index is the sum of the dimensions of the blocks of the Index.
Constructors
ITensors.Index — MethodIndex(dim::Int; tags::Union{AbstractString, TagSet} = "",
plev::Int = 0)Create an Index with a unique id, a TagSet given by tags, and a prime level plev.
Examples
julia> i = Index(2; tags="l", plev=1)
(dim=2|id=818|"l")'
julia> dim(i)
2
julia> plev(i)
1
julia> tags(i)
"l"ITensors.Index — MethodIndex(dim::Integer, tags::Union{AbstractString, TagSet}; plev::Int = 0)Create an Index with a unique id and a tagset given by tags.
Examples
julia> i = Index(2, "l,tag")
(dim=2|id=58|"l,tag")
julia> dim(i)
2
julia> plev(i)
0
julia> tags(i)
"l,tag"ITensors.Index — MethodIndex(qnblocks::Pair{QN, Int64}...; tags = "",
plev::Integer = 0)Construct a QN Index from a list of pairs of QN and block dimensions.
Example
Index(QN("Sz", -1) => 1, QN("Sz", 1) => 1; tags = "i")ITensors.Index — MethodIndex(qnblocks::Vector{Pair{QN, Int64}}; tags = "", plev::Integer = 0)Construct a QN Index from a Vector of pairs of QN and block dimensions.
Example
Index([QN("Sz", -1) => 1, QN("Sz", 1) => 1]; tags = "i")ITensors.Index — MethodIndex(qnblocks::Vector{Pair{QN, Int64}}, tags; plev::Integer = 0)Construct a QN Index from a Vector of pairs of QN and block dimensions.
Example
i = Index([QN("Sz", -1) => 1, QN("Sz", 1) => 1], "i")
idag = dag(i) # Same Index with arrow direction flippedProperties
ITensors.id — Methodid(i::Index)Obtain the id of an Index, which is a unique 64 digit integer.
ITensors.hasid — Methodhasid(i::Index, id::ITensors.IDType)Check if an Index i has the provided id.
Examples
julia> i = Index(2)
(dim=2|id=321)
julia> hasid(i, id(i))
true
julia> j = Index(2)
(dim=2|id=17)
julia> hasid(i, id(j))
falseITensors.tags — Methodtags(i::Index)Obtain the TagSet of an Index.
ITensors.TagSets.set_strict_tags! — Methodset_strict_tags!(enable::Bool) -> Bool
Enable or disable checking for overflow of the number of tags of a TagSet or the number of characters of a tag. If enabled (set to true), an error will be thrown if overflow occurs, otherwise the overflow will be ignored and the extra tags or tag characters will be dropped. This could cause unexpected bugs if tags are being used to distinguish Index objects that have the same ids and prime levels, but that is generally discouraged and should only be used if you know what you are doing.
See also ITensors.using_strict_tags.
ITensors.TagSets.using_strict_tags — Methodusing_strict_tags() -> Bool
See if checking for overflow of the number of tags of a TagSet or the number of characters of a tag is enabled or disabled.
See also ITensors.set_strict_tags!.
ITensors.TagSets.hastags — Methodhastags(i::Index, ts::Union{AbstractString,TagSet})Check if an Index i has the provided tags, which can be a string of comma-separated tags or a TagSet object.
Examples
julia> i = Index(2, "SpinHalf,Site,n=3")
(dim=2|id=861|"Site,SpinHalf,n=3")
julia> hastags(i, "SpinHalf,Site")
true
julia> hastags(i, "Link")
falseITensors.plev — Methodplev(i::Index)Obtain the prime level of an Index.
ITensors.hasplev — Methodhasplev(i::Index, plev::Int)Check if an Index i has the provided prime level.
Examples
julia> i = Index(2; plev=2)
(dim=2|id=543)''
julia> hasplev(i, 2)
true
julia> hasplev(i, 1)
falseNDTensors.dim — Methoddim(i::Index)Obtain the dimension of an Index.
For a QN Index, this is the sum of the block dimensions.
Base.:== — Method==(i1::Index, i1::Index)Compare indices for equality. First the id's are compared, then the prime levels are compared, and finally the tags are compared.
ITensors.dir — Methoddir(i::Index)Return the direction of an Index (ITensors.In, ITensors.Out, or ITensors.Neither).
ITensors.hasqns — Methodhasqns(::Index)Checks of the Index has QNs or not.
Priming and tagging methods
ITensors.prime — Methodprime(i::Index, plinc::Int = 1)Return a copy of Index i with its prime level incremented by the amount plinc
Base.adjoint — Methodadjoint(i::Index)Prime an Index using the notation i'.
Base.:^ — Method^(i::Index, pl::Int)Prime an Index using the notation i^3.
ITensors.setprime — Methodsetprime(i::Index, plev::Int)Return a copy of Index i with its prime level set to plev
ITensors.noprime — Methodnoprime(i::Index)Return a copy of Index i with its prime level set to zero.
ITensors.settags — Methodsettags(i::Index, ts)Return a copy of Index i with tags replaced by the ones given The ts argument can be a comma-separated string of tags or a TagSet.
Examples
julia> i = Index(2, "SpinHalf,Site,n=3")
(dim=2|id=543|"Site,SpinHalf,n=3")
julia> hastags(i, "Link")
false
julia> j = settags(i, "Link,n=4")
(dim=2|id=543|"Link,n=4")
julia> hastags(j, "Link")
true
julia> hastags(j, "n=4,Link")
trueITensors.TagSets.addtags — Methodaddtags(i::Index,ts)Return a copy of Index i with the specified tags added to the existing ones. The ts argument can be a comma-separated string of tags or a TagSet.
ITensors.TagSets.removetags — Methodremovetags(i::Index, ts)Return a copy of Index i with the specified tags removed. The ts argument can be a comma-separated string of tags or a TagSet.
ITensors.TagSets.replacetags — Methodreplacetags(i::Index, tsold, tsnew)
replacetags(i::Index, tsold => tsnew)If the tag set of i contains the tags specified by tsold, replaces these with the tags specified by tsnew, preserving any other tags. The arguments tsold and tsnew can be comma-separated strings of tags, or TagSet objects.
Examples
julia> i = Index(2; tags="l,x", plev=1)
(dim=2|id=83|"l,x")'
julia> replacetags(i, "l", "m")
(dim=2|id=83|"m,x")'
julia> replacetags(i, "l" => "m")
(dim=2|id=83|"m,x")'Methods
NDTensors.sim — Methodsim(i::Index; tags = tags(i), plev = plev(i))Produces an Index with the same properties (dimension or QN structure) but with a new id.
ITensors.dag — Methoddag(i::Index)Copy an index i and reverse its direction.
ITensors.removeqns — Methodremoveqns(::Index)Removes the QNs from the Index, if it has any.
Iterating
ITensors.eachval — Methodeachval(i::Index)Create an iterator whose values range over the dimension of the provided Index.
ITensors.eachindval — Methodeachindval(i::Index)Create an iterator whose values are Pairs of the form i=>n with n from 1:dim(i). This iterator is useful for accessing elements of an ITensor in a loop without needing to know the ordering of the indices. See also eachindval(is::Index...).