Skip to content

Commit

Permalink
Fix tensor selection inside contract
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Dec 4, 2023
1 parent 2f77210 commit 7bf04a6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/TensorNetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ The `kwargs` will be passed down to the [`einexpr`](@ref) function.
See also: [`einexpr`](@ref), [`contract!`](@ref).
"""
function contract(tn::AbstractTensorNetwork; path = einexpr(tn))
# TODO does `first` work always?
length(path.args) == 0 && return select(tn, inds(path)) |> first
length(path.args) == 0 && return tn[inds(path)...]

intermediates = map(subpath -> contract(tn; path = subpath), path.args)
contract(intermediates...; dims = suminds(path))
Expand Down

0 comments on commit 7bf04a6

Please sign in to comment.