Hi Jin,
This works as expected for me with the latest version of ITensors.jl:
pkg> st ITensors
Status [...]
[9136182c] ITensors v0.1.30
julia> using ITensors
julia> s = Index([QN(("N",i,3))=>1 for i = 0:(2)];dir = ITensors.Arrow(1))
(dim=3|id=859) <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> l = setdir(addtags(s,"left"),ITensors.Arrow(-1))
(dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> r = addtags(s,"right")
(dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> A = emptyITensor(l,r)
ITensor ord=2
(dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
(dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
NDTensors.Empty{Float64,NDTensors.BlockSparse{Float64,Array{Float64,1},2}}
julia> A[l(1),r(1)] = 1.0
1.0
julia> @show A;
A = ITensor ord=2
Dim 1: (dim=3|id=859|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
Dim 2: (dim=3|id=859|"right") <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
NDTensors.BlockSparse{Float64,Array{Float64,1},2}
3×3
Block: Block{2}((0x0000000000000001, 0x0000000000000001), 0xa03b74afc6984a6a)
[1:1, 1:1]
1.0
We've been making quite a few changes to indexing and block sparse operations in recent versions, so possibly something broke in one of the versions before v0.1.30.
Also note that the Index direction is out by default, and you can make a new Index with the arrow direction reversed with dag
:
julia> s = Index([QN("N",i,3)=>1 for i = 0:2])
(dim=3|id=917) <Out>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
julia> l = dag(addtags(s,"left"))
(dim=3|id=917|"left") <In>
1: QN("N",0,3) => 1
2: QN("N",1,3) => 1
3: QN("N",2,3) => 1
-Matt