Skip to content

Commit

Permalink
Add support for building operators without a link space (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 authored May 14, 2024
1 parent c87775d commit 2ca5129
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/abstractindsnetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ function insert_linkinds(
for e in edges
# TODO: Change to check if it is empty.
if !isassigned(indsnetwork, e)
iₑ = Index(link_space, edge_tag(e))
# TODO: Allow setting with just `Index`.
indsnetwork[e] = [iₑ]
if !isnothing(link_space)
iₑ = Index(link_space, edge_tag(e))
# TODO: Allow setting with just `Index`.
indsnetwork[e] = [iₑ]
else
indsnetwork[e] = []
end
end
end
return indsnetwork
Expand Down
3 changes: 2 additions & 1 deletion src/formnetworks/bilinearformnetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ function BilinearFormNetwork(
kwargs...,
)
@assert issetequal(flatten_siteinds(bra), flatten_siteinds(ket))
link_space = isempty(flatten_siteinds(bra)) ? 1 : nothing
operator_inds = union_all_inds(siteinds(ket), dual_site_index_map(siteinds(ket)))
# TODO: Define and use `identity_network` here.
O = ITensorNetwork(Op("I"), operator_inds)
O = ITensorNetwork(Op("I"), operator_inds; link_space)
return BilinearFormNetwork(O, bra, ket; dual_site_index_map, kwargs...)
end

Expand Down
5 changes: 1 addition & 4 deletions src/gauging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function Base.copy(ψ::VidalITensorNetwork)
return VidalITensorNetwork(copy(site_tensors(ψ)), copy(bond_tensors(ψ)))
end

function default_norm_cache::ITensorNetwork)
ψψ = norm_sqr_network(ψ)
return BeliefPropagationCache(ψψ, group(v -> first(v), vertices(ψψ)))
end
default_norm_cache::ITensorNetwork) = BeliefPropagationCache(QuadraticFormNetwork(ψ))

function ITensorNetwork(
ψ_vidal::VidalITensorNetwork; (cache!)=nothing, update_gauge=false, update_kwargs...
Expand Down

0 comments on commit 2ca5129

Please sign in to comment.