Skip to content

Commit

Permalink
refactor expect to avoid calling evolve!
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Nov 2, 2024
1 parent 4849c69 commit e1970fd
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Ansatz/Ansatz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ end

overlap(a::AbstractAnsatz, b::AbstractAnsatz) = contract(merge(a, copy(b)'))

function expect::AbstractAnsatz, observable; bra=copy(ψ))
ϕ = bra
evolve!(ϕ, observable)
return overlap(ϕ, ψ)
end
expect::AbstractAnsatz, observable; bra=copy(ψ)) = contract(merge(ψ, observable, bra'))

function expect::AbstractAnsatz, observables::AbstractVecOrTuple; bra=copy(ψ))
sum(observables) do observable
Expand Down

0 comments on commit e1970fd

Please sign in to comment.