Skip to content

Commit

Permalink
Expectation value is a real quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWeaving committed Nov 28, 2023
1 parent da42a45 commit f35bac8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions symmer/operators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def expval(self, psi: "QuantumState") -> complex:
complex: The expectation value.
"""
if self.n_terms > psi.n_terms:
return psi.dagger * self * psi
return (psi.dagger * self * psi).real
else:
if self.n_terms > 1:
@process.parallelize
Expand All @@ -841,7 +841,7 @@ def f(P, psi):
else:
expvals = np.array(single_term_expval(self, psi))

return np.sum(expvals * self.coeff_vec)
return np.sum(expvals * self.coeff_vec).real

def __mul__(self,
mul_obj: Union["PauliwordOp", "QuantumState", complex],
Expand Down

0 comments on commit f35bac8

Please sign in to comment.