From e9610e9660637762b67c8dd5f30f49799b55f770 Mon Sep 17 00:00:00 2001 From: Joey Date: Tue, 26 Nov 2024 15:03:01 -0500 Subject: [PATCH] Make gauge edge lowest level function --- src/abstractitensornetwork.jl | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/abstractitensornetwork.jl b/src/abstractitensornetwork.jl index afdbbb41..73c915a1 100644 --- a/src/abstractitensornetwork.jl +++ b/src/abstractitensornetwork.jl @@ -586,38 +586,37 @@ function LinearAlgebra.factorize(tn::AbstractITensorNetwork, edge::Pair; kwargs. end # For ambiguity error; TODO: decide whether to use graph mutating methods when resulting graph is unchanged? -function gauge_walk( - alg::Algorithm, tn::AbstractITensorNetwork, edge::AbstractEdge; kwargs... +function gauge_edge( + alg::Algorithm"orthogonalize", tn::AbstractITensorNetwork, edge::AbstractEdge; kwargs... ) - return gauge_walk(tn, [edge]; kwargs...) -end - -function gauge_walk(alg::Algorithm, tn::AbstractITensorNetwork, edge::Pair; kwargs...) - return gauge_walk(alg::Algorithm, tn, edgetype(tn)(edge); kwargs...) + # tn = factorize(tn, edge; kwargs...) + # # TODO: Implement as `only(common_neighbors(tn, src(edge), dst(edge)))` + # new_vertex = only(neighbors(tn, src(edge)) ∩ neighbors(tn, dst(edge))) + # return contract(tn, new_vertex => dst(edge)) + tn = copy(tn) + left_inds = uniqueinds(tn, edge) + ltags = tags(tn, edge) + X, Y = factorize(tn[src(edge)], left_inds; tags=ltags, ortho="left", kwargs...) + tn[src(edge)] = X + tn[dst(edge)] *= Y + return tn end # For ambiguity error; TODO: decide whether to use graph mutating methods when resulting graph is unchanged? function gauge_walk( - alg::Algorithm"orthogonalize", - tn::AbstractITensorNetwork, - edges::Vector{<:AbstractEdge}; - kwargs..., + alg::Algorithm, tn::AbstractITensorNetwork, edges::Vector{<:AbstractEdge}; kwargs... ) - # tn = factorize(tn, edge; kwargs...) - # # TODO: Implement as `only(common_neighbors(tn, src(edge), dst(edge)))` - # new_vertex = only(neighbors(tn, src(edge)) ∩ neighbors(tn, dst(edge))) - # return contract(tn, new_vertex => dst(edge)) tn = copy(tn) for edge in edges - left_inds = uniqueinds(tn, edge) - ltags = tags(tn, edge) - X, Y = factorize(tn[src(edge)], left_inds; tags=ltags, ortho="left", kwargs...) - tn[src(edge)] = X - tn[dst(edge)] *= Y + tn = gauge_edge(alg, tn, edge; kwargs...) end return tn end +function gauge_walk(alg::Algorithm, tn::AbstractITensorNetwork, edge::Pair; kwargs...) + return gauge_edge(alg::Algorithm, tn, edgetype(tn)(edge); kwargs...) +end + function gauge_walk( alg::Algorithm, tn::AbstractITensorNetwork, edges::Vector{<:Pair}; kwargs... )