Skip to content

Commit

Permalink
Construct correct identity_network in BiLinearFormNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Apr 12, 2024
1 parent ec3e840 commit 0026623
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/formnetworks/bilinearformnetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function BilinearFormNetwork(
)
@assert issetequal(externalinds(bra), externalinds(ket))
operator_inds = union_all_inds(siteinds(ket), dual_site_index_map(siteinds(ket)))
O = delta_network(operator_inds)
O = ITensorNetwork(Op("I"), operator_inds)
return BilinearFormNetwork(O, bra, ket; dual_site_index_map, kwargs...)
end

Expand Down
12 changes: 8 additions & 4 deletions src/itensornetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ function generic_state(a::AbstractArray, inds::Vector)
end
function generic_state(x::Op, inds::NamedTuple)
# TODO: Figure out what to do if there is more than one site.
@assert length(inds.siteinds) == 2
i = inds.siteinds[findfirst(i -> plev(i) == 0, inds.siteinds)]
@assert i' inds.siteinds
site_tensors = [op(x.which_op, i)]
if !isempty(inds.siteinds)
@assert length(inds.siteinds) == 2
i = inds.siteinds[findfirst(i -> plev(i) == 0, inds.siteinds)]
@assert i' inds.siteinds
site_tensors = [op(x.which_op, i)]
else
site_tensors = []
end
link_tensors = [[onehot(i => 1) for i in inds.linkinds[e]] for e in keys(inds.linkinds)]
return contract(reduce(vcat, link_tensors; init=site_tensors))
end
Expand Down
1 change: 0 additions & 1 deletion test/test_forms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ using ITensorNetworks:
QuadraticFormNetwork,
bra_network,
bra_vertex,
delta_network,
dual_index_map,
environment,
externalinds,
Expand Down

0 comments on commit 0026623

Please sign in to comment.