In and Out in quantum number index and where to get the helpful document

I am trying to use the quantum number index (QN index) to write a TRG program with symmetry. It is important to specify the ''Arrow" of the index when there is symmetry involved. Or more mathematically, group acts differently on a vector space and its dual.

I read that in the page 27 of ITensor paper, there is a way to specify whether a index is ingoing or outgoing to a tensor. However, when I searched for In and Out, I can not find reference for Julia. Instead, an example in C++ says one should write In or Out when defining the Index. So I imitate this in Julia:

l = Index(QN("Z2", 0, 2) => 1, QN("Z2", 1, 2) => 1, In; tags = "left")

but this reports error.

Another related question. In example of TRG, a function called filterinds is used:

sₕ, sᵥ = filterinds(T; plev=0)

This makes the trg function very elegant since one does not need to convey indices. However, I also cannot find the reference for this function in online document.

Is there a more comprehensive document for ITensors? Or where should I learn it?


The index problem has been proposed and answered in https://itensor.discourse.group/t/index-direction/977/3

It seems there is no documentation for that particular function. In general all other documentation (which should be the same as online) can be found in Julia’s help mode by typing ?

help?> filterinds
search: filterinds

  No documentation found.

  ITensors.filterinds is a Function.

  # 4 methods for generic function "filterinds" from ITensors:
   [1] filterinds(A::ITensor)
       @ ~/.julia/packages/ITensors/36lEH/src/itensor.jl:1519
   [2] filterinds(is::Union{Tuple{Vararg{IndexT}}, Vector{IndexT}} where IndexT<:Index)
       @ ~/.julia/packages/ITensors/36lEH/src/itensor.jl:1520
   [3] filterinds(f::Function, A...)
       @ ~/.julia/packages/ITensors/36lEH/src/itensor.jl:1515
   [4] filterinds(A...; kwargs...)
       @ ~/.julia/packages/ITensors/36lEH/src/itensor.jl:1516

Quick note, you can make your own filter function by using built in Julia functions as well

sₕ, sᵥ =  filter(iv -> hasplev(iv,0), inds(T))
1 Like

Thank you!

1 Like

Another question: since the order of indices are not emphasized in ITensors, how can I make sure that the filtered index is in the order of horizontal and vertical?

You’ll see the filterinds is only used for an assert at the beginning of the code for that reason. Elsewhere they are found via (for example) s̃ₕ = commonind(Fₕ, Fₕ′) where you can be sure its the correct index.

An alternative I can also think of is creating a custom tag to differentiate the indices, which you can sort of see in action in ctmrg_anisotropic.jl

1 Like

Thank you, I will try in this way!

1 Like

Also, I don’t know if Ryan mentioned already, but you can type ITensors.In and ITensors.Out or do using ITensors: In, Out to get those variables. We don’t export them by default because they are very common names and we already found one example where they conflict with a different library.

Glad you are trying out ITensor for your project!

2 Likes

Also, I have rarely if ever found cases where using ITensors.In and ITensors.Out explicitly is needed (except deep down in the internal code of ITensors.jl), that is usually an indication that you are designing your code in the wrong way. It is better to, for example, define only indices with Out arrows (using the default Index constructor where you don’t specify the arrow direction) and then use dag to construct versions of those indices with the opposite arrow direction as needed.

2 Likes

Thanks for your suggestion!

Thanks for your answer. Your guys’ package is really elegant not only in programming but also in mathematics!