|
1 | 1 | using Adapt: adapt |
2 | 2 | using DataGraphs: DataGraphs, set_vertex_data! |
3 | | -using Dictionaries: Dictionary, set! |
4 | 3 | using ITensors.NDTensors: datatype, denseblocks |
5 | | -using ITensors: ITensor, Index, Op, commoninds, dag, delta, prime, sim |
| 4 | +using ITensors: ITensor, Index, Op, dag, delta, prime, sim |
6 | 5 | using NamedGraphs.GraphsExtensions: disjoint_union |
7 | | -using NamedGraphs.PartitionedGraphs: |
8 | | - PartitionedGraph, QuotientEdge, partitioned_vertices, quotientedges |
9 | 6 |
|
10 | 7 | default_dual_site_index_map = prime |
11 | 8 | default_dual_link_index_map = sim |
@@ -108,50 +105,3 @@ function update( |
108 | 105 | tensornetwork(blf)[ket_vertex(blf, original_ket_state_vertex)] = ket_state |
109 | 106 | return blf |
110 | 107 | end |
111 | | - |
112 | | -# Initial BP messages from bra↔ket pairings on each quotient edge. |
113 | | -# Errors when the operator subnet has its own inter-vertex links (the |
114 | | -# multi-site-operator case): those legs are operator-internal and have |
115 | | -# no bra/ket pair, so no canonical identity initialization exists — the |
116 | | -# caller must supply `messages` explicitly. |
117 | | -function identity_messages(fn::BilinearFormNetwork, ptn::PartitionedGraph) |
118 | | - pairings = Dictionary{QuotientEdge, Pair{Vector{Index}, Vector{Index}}}() |
119 | | - tn = tensornetwork(fn) |
120 | | - pv = partitioned_vertices(ptn) |
121 | | - ket_s = ket_vertex_suffix(fn) |
122 | | - for pe in quotientedges(ptn) |
123 | | - src_orig = unique(first.(filter(v -> last(v) == ket_s, pv[parent(src(pe))]))) |
124 | | - dst_orig = unique(first.(filter(v -> last(v) == ket_s, pv[parent(dst(pe))]))) |
125 | | - for v_from in src_orig, v_to in dst_orig |
126 | | - op_inds = commoninds( |
127 | | - tn[operator_vertex(fn, v_from)], tn[operator_vertex(fn, v_to)] |
128 | | - ) |
129 | | - if !isempty(op_inds) |
130 | | - error( |
131 | | - "BilinearFormNetwork: operator-internal cross-Index between " * |
132 | | - "$v_from and $v_to has no bra/ket pair; supply `messages` " * |
133 | | - "explicitly to BP." |
134 | | - ) |
135 | | - end |
136 | | - end |
137 | | - for (from_orig, to_orig, e) in ( |
138 | | - (src_orig, dst_orig, pe), |
139 | | - (dst_orig, src_orig, reverse(pe)), |
140 | | - ) |
141 | | - bras = Index[] |
142 | | - kets = Index[] |
143 | | - for v_from in from_orig, v_to in to_orig |
144 | | - append!( |
145 | | - bras, |
146 | | - commoninds(tn[bra_vertex(fn, v_from)], tn[bra_vertex(fn, v_to)]) |
147 | | - ) |
148 | | - append!( |
149 | | - kets, |
150 | | - commoninds(tn[ket_vertex(fn, v_from)], tn[ket_vertex(fn, v_to)]) |
151 | | - ) |
152 | | - end |
153 | | - set!(pairings, e, bras => kets) |
154 | | - end |
155 | | - end |
156 | | - return identity_messages(scalartype(tn), pairings) |
157 | | -end |
0 commit comments