Skip to content

Commit

Permalink
Revert expect
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Jun 16, 2024
1 parent 0704609 commit e1344f0
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/expect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ using ITensorMPS: ITensorMPS, expect

default_expect_alg() = "bp"

function ITensorMPS.expect(
ψ::AbstractITensorNetwork, ops; alg=default_expect_alg(), kwargs...
)
return expect(Algorithm(alg), ψ, ops; kwargs...)
end

function ITensorMPS.expect(
ψIψ::AbstractFormNetwork, op::Op; contract_kwargs=(; sequence="automatic"), kwargs...
)
Expand All @@ -24,27 +18,6 @@ function ITensorMPS.expect(
return numerator / denominator
end

function ITensorMPS.expect(
ψIψ::AbstractFormNetwork,
ops::Scaled{ComplexF64,Prod{Op}};
contract_kwargs=(; sequence="automatic"),
kwargs...,
)
scalar = first(ops.args)
iszero(scalar) && return 0.0
n_ops = length(ops)
vs = site.(ops[1:n_ops])
op_strings = which_op.(ops[1:n_ops])
ψIψ_vs = [ψIψ[operator_vertex(ψIψ, v)] for v in vs]
sinds = [commonind(ψIψ[ket_vertex(ψIψ, v)], ψIψ_vs[i]) for (i, v) in enumerate(vs)]
operators = [ITensors.op(op_strings[i], sinds[i]) for i in 1:n_ops]
∂ψIψ_∂v = environment(ψIψ, operator_vertices(ψIψ, vs); kwargs...)
numerator = contract(vcat(∂ψIψ_∂v, operators); contract_kwargs...)[]
denominator = contract(vcat(∂ψIψ_∂v, ψIψ_vs); contract_kwargs...)[]

return scalar * numerator / denominator
end

function ITensorMPS.expect(
alg::Algorithm,
ψ::AbstractITensorNetwork,
Expand Down

0 comments on commit e1344f0

Please sign in to comment.