Skip to content

Commit

Permalink
test: simplify array expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Sep 14, 2023
1 parent 82963e2 commit 21f7636
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions pyquil/paulis.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,29 +988,15 @@ def exponentiate_pauli_sum(
>>> coeff = phi/(-4*pi) # -0.25
>>> hamiltonian = PauliTerm("Z", 0) * PauliTerm("Z", 1) - 1*PauliTerm("Z", 0) - 1*PauliTerm("Z", 1)
>>> exponentiate_pauli_sum(coeff*hamiltonian)
array([[ 1.-1.11022302e-16j, 0.+0.00000000e+00j, 0.+0.00000000e+00j,
0.+0.00000000e+00j],
[ 0.+0.00000000e+00j, 1.-1.11022302e-16j, 0.+0.00000000e+00j,
0.+0.00000000e+00j],
[ 0.+0.00000000e+00j, 0.+0.00000000e+00j, 1.-1.11022302e-16j,
0.+0.00000000e+00j],
[ 0.+0.00000000e+00j, 0.+0.00000000e+00j, 0.+0.00000000e+00j,
-1.+2.22044605e-16j]])
array([[...]])
To produce the Quil XY(theta) gate, you can use:
>>> theta = pi/2
>>> coeff = theta/(-4*pi)
>>> hamiltonian = PauliTerm("X", 0) * PauliTerm("X", 1) + PauliTerm("Y", 0) * PauliTerm("Y", 1)
>>> exponentiate_pauli_sum(coeff*hamiltonian)
array([[1. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
[0. +0.j , 0.70710678+0.j ,
0. +0.70710678j, 0. +0.j ],
[0. +0.j , 0. +0.70710678j,
0.70710678+0.j , 0. +0.j ],
[0. +0.j , 0. +0.j ,
0. +0.j , 1. +0.j ]])
array([[...]])
A global phase is applied to the unitary such that the [0,0] element is always real.
Expand Down

0 comments on commit 21f7636

Please sign in to comment.