Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"

[compat]
AbstractTrees = "0.4.4"
Expand All @@ -54,6 +55,7 @@ SplitApplyCombine = "1.2"
StaticArrays = "1.5.12"
Suppressor = "0.2"
TimerOutputs = "0.5.22"
TupleTools = "1.4"
julia = "1.7"

[extras]
Expand Down
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ and 3 edge(s):
3 => 4

with vertex data:
4-element Dictionaries.Dictionary{Int64, Any}
1 │ ((dim=2|id=739|"12"),)
2 │ ((dim=2|id=739|"12"), (dim=2|id=920|"23"))
3 │ ((dim=2|id=920|"23"), (dim=2|id=761|"34"))
4 │ ((dim=2|id=761|"34"),)
4-element Dictionary{Int64, Any}
1 │ ((dim=2|id=739|"1,2"),)
2 │ ((dim=2|id=739|"1,2"), (dim=2|id=920|"2,3"))
3 │ ((dim=2|id=920|"2,3"), (dim=2|id=761|"3,4"))
4 │ ((dim=2|id=761|"3,4"),)

julia> tn[1]
ITensor ord=1 (dim=2|id=739|"12")
ITensor ord=1 (dim=2|id=739|"1,2")
NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}

julia> tn[2]
ITensor ord=2 (dim=2|id=739|"12") (dim=2|id=920|"23")
ITensor ord=2 (dim=2|id=739|"1,2") (dim=2|id=920|"2,3")
NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}

julia> neighbors(tn, 1)
Expand Down Expand Up @@ -88,14 +88,14 @@ and 4 edge(s):
(1, 2) => (2, 2)

with vertex data:
4-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any}
(1, 1) │ ((dim=2|id=74|"1×12×1"), (dim=2|id=723|"1×11×2"))
(2, 1) │ ((dim=2|id=74|"1×12×1"), (dim=2|id=823|"2×12×2"))
(1, 2) │ ((dim=2|id=723|"1×11×2"), (dim=2|id=712|"1×22×2"))
(2, 2) │ ((dim=2|id=823|"2×12×2"), (dim=2|id=712|"1×22×2"))
4-element Dictionary{Tuple{Int64, Int64}, Any}
(1, 1) │ ((dim=2|id=74|"1×1,2×1"), (dim=2|id=723|"1×1,1×2"))
(2, 1) │ ((dim=2|id=74|"1×1,2×1"), (dim=2|id=823|"2×1,2×2"))
(1, 2) │ ((dim=2|id=723|"1×1,1×2"), (dim=2|id=712|"1×2,2×2"))
(2, 2) │ ((dim=2|id=823|"2×1,2×2"), (dim=2|id=712|"1×2,2×2"))

julia> tn[1, 1]
ITensor ord=2 (dim=2|id=74|"1×12×1") (dim=2|id=723|"1×11×2")
ITensor ord=2 (dim=2|id=74|"1×1,2×1") (dim=2|id=723|"1×1,1×2")
NDTensors.EmptyStorage{NDTensors.EmptyNumber, NDTensors.Dense{NDTensors.EmptyNumber, Vector{NDTensors.EmptyNumber}}}

julia> neighbors(tn, (1, 1))
Expand All @@ -118,9 +118,9 @@ and 1 edge(s):
(1, 1) => (1, 2)

with vertex data:
2-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any}
(1, 1) │ ((dim=2|id=74|"1×12×1"), (dim=2|id=723|"1×11×2"))
(1, 2) │ ((dim=2|id=723|"1×11×2"), (dim=2|id=712|"1×22×2"))
2-element Dictionary{Tuple{Int64, Int64}, Any}
(1, 1) │ ((dim=2|id=74|"1×1,2×1"), (dim=2|id=723|"1×1,1×2"))
(1, 2) │ ((dim=2|id=723|"1×1,1×2"), (dim=2|id=712|"1×2,2×2"))

julia> tn_2 = subgraph(v -> v[1] == 2, tn)
ITensorNetwork{Tuple{Int64, Int64}} with 2 vertices:
Expand All @@ -132,9 +132,9 @@ and 1 edge(s):
(2, 1) => (2, 2)

with vertex data:
2-element Dictionaries.Dictionary{Tuple{Int64, Int64}, Any}
(2, 1) │ ((dim=2|id=74|"1×12×1"), (dim=2|id=823|"2×12×2"))
(2, 2) │ ((dim=2|id=823|"2×12×2"), (dim=2|id=712|"1×22×2"))
2-element Dictionary{Tuple{Int64, Int64}, Any}
(2, 1) │ ((dim=2|id=74|"1×1,2×1"), (dim=2|id=823|"2×1,2×2"))
(2, 2) │ ((dim=2|id=823|"2×1,2×2"), (dim=2|id=712|"1×2,2×2"))
```


Expand All @@ -155,13 +155,13 @@ and 2 edge(s):
2 => 3

with vertex data:
3-element Dictionaries.Dictionary{Int64, Vector{Index}}
3-element Dictionary{Int64, Vector{Index}}
1 │ Index[(dim=2|id=598|"S=1/2,Site,n=1")]
2 │ Index[(dim=2|id=457|"S=1/2,Site,n=2")]
3 │ Index[(dim=2|id=683|"S=1/2,Site,n=3")]

and edge data:
0-element Dictionaries.Dictionary{NamedEdge{Int64}, Vector{Index}}
0-element Dictionary{NamedEdge{Int64}, Vector{Index}}

julia> tn1 = ITensorNetwork(s; link_space=2)
ITensorNetwork{Int64} with 3 vertices:
Expand All @@ -175,10 +175,10 @@ and 2 edge(s):
2 => 3

with vertex data:
3-element Dictionaries.Dictionary{Int64, Any}
1 │ ((dim=2|id=598|"S=1/2,Site,n=1"), (dim=2|id=123|"12"))
2 │ ((dim=2|id=457|"S=1/2,Site,n=2"), (dim=2|id=123|"12"), (dim=2|id=656|"23…
3 │ ((dim=2|id=683|"S=1/2,Site,n=3"), (dim=2|id=656|"23"))
3-element Dictionary{Int64, Any}
1 │ ((dim=2|id=598|"S=1/2,Site,n=1"), (dim=2|id=123|"1,2"))
2 │ ((dim=2|id=457|"S=1/2,Site,n=2"), (dim=2|id=123|"1,2"), (dim=2|id=656|"2,3…
3 │ ((dim=2|id=683|"S=1/2,Site,n=3"), (dim=2|id=656|"2,3"))

julia> tn2 = ITensorNetwork(s; link_space=2)
ITensorNetwork{Int64} with 3 vertices:
Expand All @@ -192,10 +192,10 @@ and 2 edge(s):
2 => 3

with vertex data:
3-element Dictionaries.Dictionary{Int64, Any}
1 │ ((dim=2|id=598|"S=1/2,Site,n=1"), (dim=2|id=382|"12"))
2 │ ((dim=2|id=457|"S=1/2,Site,n=2"), (dim=2|id=382|"12"), (dim=2|id=190|"23…
3 │ ((dim=2|id=683|"S=1/2,Site,n=3"), (dim=2|id=190|"23"))
3-element Dictionary{Int64, Any}
1 │ ((dim=2|id=598|"S=1/2,Site,n=1"), (dim=2|id=382|"1,2"))
2 │ ((dim=2|id=457|"S=1/2,Site,n=2"), (dim=2|id=382|"1,2"), (dim=2|id=190|"2,3…
3 │ ((dim=2|id=683|"S=1/2,Site,n=3"), (dim=2|id=190|"2,3"))

julia> @visualize tn1;
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand Down
4 changes: 3 additions & 1 deletion src/treetensornetworks/abstracttreetensornetwork.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using TupleTools: TupleTools

abstract type AbstractTreeTensorNetwork{V} <: AbstractITensorNetwork{V} end

const AbstractTTN = AbstractTreeTensorNetwork
Expand Down Expand Up @@ -334,7 +336,7 @@ function permute(ψ::AbstractTTN, ::Tuple{typeof(linkind),typeof(siteinds),typeo
ψ̃ = copy(ψ)
for v in vertices(ψ)
ls = [only(linkinds(ψ, n => v)) for n in neighbors(ψ, v)] # TODO: won't work for multiple indices per link...
ss = sort(Tuple(siteinds(ψ, v)); by=plev)
ss = TupleTools.sort(Tuple(siteinds(ψ, v)); by=plev)
setindex_preserve_graph!(
ψ̃, permute(ψ[v], filter(!isnothing, (ls[1], ss..., ls[2:end]...))), v
)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
GraphsFlows = "06909019-6f44-4949-96fc-b9d9aaa02889"
ITensorNetworks = "2919e153-833c-4bdc-8836-1ea460a35fc7"
ITensorUnicodePlots = "73163f41-4a9e-479f-8353-73bf94dbd758"
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
KaHyPar = "2a6221f6-aa48-11e9-3542-2d9e0ef01880"
Expand Down