Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 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: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ITensorNetworks"
uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7"
authors = ["Matthew Fishman <[email protected]>, Joseph Tindall <[email protected]> and contributors"]
version = "0.12.0"
version = "0.12.1"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
4 changes: 2 additions & 2 deletions src/ITensorNetworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ include("specialitensornetworks.jl")
include("boundarymps.jl")
include("partitioneditensornetwork.jl")
include("edge_sequences.jl")
include("caches/abstractbeliefpropagationcache.jl")
include("caches/beliefpropagationcache.jl")
include("formnetworks/abstractformnetwork.jl")
include("formnetworks/bilinearformnetwork.jl")
include("formnetworks/quadraticformnetwork.jl")
include("caches/abstractbeliefpropagationcache.jl")
include("caches/beliefpropagationcache.jl")
include("contraction_tree_to_graph.jl")
include("gauging.jl")
include("utils.jl")
Expand Down
40 changes: 33 additions & 7 deletions src/abstractitensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -623,18 +623,44 @@ function gauge_walk(
return gauge_walk(alg, tn, edgetype(tn).(edges); kwargs...)
end

function tree_gauge(alg::Algorithm, ψ::AbstractITensorNetwork, region)
return tree_gauge(alg, ψ, [region])
end

#Get the path that moves the gauge from a to b on a tree
#TODO: Move to NamedGraphs
function gauge_path(g::AbstractGraph, region_a::Vector, region_b::Vector)
issetequal(region_a, region_b) && return edgetype(g)[]
st = steiner_tree(g, union(region_a, region_b))
path = post_order_dfs_edges(st, first(region_b))
path = filter(e -> !((src(e) ∈ region_b) && (dst(e) ∈ region_b)), path)
return path
end

# Gauge a ITensorNetwork from cur_region towards new_region, treating
# the network as a tree spanned by a spanning tree.
function tree_gauge(
alg::Algorithm,
ψ::AbstractITensorNetwork,
cur_region::Vector,
new_region::Vector;
kwargs...,
)
path = gauge_path(ψ, cur_region, new_region)
if !isempty(path)
ψ = gauge_walk(alg, ψ, path; kwargs...)
end
return ψ
end

# Gauge a ITensorNetwork towards a region, treating
# the network as a tree spanned by a spanning tree.
function tree_gauge(alg::Algorithm, ψ::AbstractITensorNetwork, region::Vector)
region_center =
length(region) != 1 ? first(center(steiner_tree(ψ, region))) : only(region)
path = post_order_dfs_edges(bfs_tree(ψ, region_center), region_center)
path = filter(e -> !((src(e) ∈ region) && (dst(e) ∈ region)), path)
return gauge_walk(alg, ψ, path)
return tree_gauge(alg, ψ, collect(vertices(ψ)), region)
end

function tree_gauge(alg::Algorithm, ψ::AbstractITensorNetwork, region)
return tree_gauge(alg, ψ, [region])
function tree_orthogonalize(ψ::AbstractITensorNetwork, cur_region, new_region; kwargs...)
return tree_gauge(Algorithm("orthogonalize"), ψ, cur_region, new_region; kwargs...)
end

function tree_orthogonalize(ψ::AbstractITensorNetwork, region; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function ITensors.apply(o, ψ::VidalITensorNetwork; normalize=false, apply_kwarg

else
updated_ψ = apply(o, updated_ψ; normalize)
return VidalITensorNetwork(ψ, updated_bond_tensors)
return VidalITensorNetwork(updated_ψ, updated_bond_tensors)
end
end

Expand Down
3 changes: 0 additions & 3 deletions src/caches/abstractbeliefpropagationcache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ default_messages(ptn::PartitionedGraph) = Dictionary()
return default_bp_maxiter(undirected_graph(underlying_graph(g)))
end
default_partitioned_vertices(ψ::AbstractITensorNetwork) = group(v -> v, vertices(ψ))
function default_partitioned_vertices(f::AbstractFormNetwork)
return group(v -> original_state_vertex(f, v), vertices(f))
end

partitioned_tensornetwork(bpc::AbstractBeliefPropagationCache) = not_implemented()
messages(bpc::AbstractBeliefPropagationCache) = not_implemented()
Expand Down
4 changes: 4 additions & 0 deletions src/formnetworks/abstractformnetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ operator_vertex(f::AbstractFormNetwork, v) = operator_vertex_map(f)(v)
bra_vertex(f::AbstractFormNetwork, v) = bra_vertex_map(f)(v)
ket_vertex(f::AbstractFormNetwork, v) = ket_vertex_map(f)(v)
original_state_vertex(f::AbstractFormNetwork, v) = inv_vertex_map(f)(v)

function default_partitioned_vertices(f::AbstractFormNetwork)
return group(v -> original_state_vertex(f, v), vertices(f))
end
8 changes: 1 addition & 7 deletions src/treetensornetworks/abstracttreetensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ function set_ortho_region(tn::AbstractTTN, new_region)
end

function gauge(alg::Algorithm, ttn::AbstractTTN, region::Vector; kwargs...)
issetequal(region, ortho_region(ttn)) && return ttn
st = steiner_tree(ttn, union(region, ortho_region(ttn)))
path = post_order_dfs_edges(st, first(region))
path = filter(e -> !((src(e) ∈ region) && (dst(e) ∈ region)), path)
if !isempty(path)
ttn = typeof(ttn)(gauge_walk(alg, ITensorNetwork(ttn), path; kwargs...))
end
ttn = tree_gauge(alg, ttn, collect(ortho_region(ttn)), region; kwargs...)
return set_ortho_region(ttn, region)
end

Expand Down
Loading