Skip to content

Commit

Permalink
Add xy test (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Davis authored and Robert Smith committed Nov 19, 2019
1 parent 32da8d4 commit c7d1b15
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/gate-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@
(run qvm)
(is (double-float= 1 (probability (aref amps 0)) 1/10000)))))

(deftest test-xy-gate ()
"Test that XY gates are supported, and are equivalent to PISWAP gates."
(dotimes (i 10)
(let ((amps (qvm::randomize-wavefunction (qvm::wf 1.0 0.0 0.0 0.0))))
(flet ((eval-prog (quil-string)
(let ((qvm (make-qvm 2)))
(load-program qvm (quil:parse-quil quil-string))
(setf (qvm::amplitudes qvm) (qvm::copy-wavefunction amps))
(setf qvm (run qvm))
(qvm::amplitudes qvm))))
(let ((xy-wf (eval-prog "XY(pi/2) 1 0"))
(piswap-wf (eval-prog "PISWAP(pi/2) 1 0")))
(is (every #'cflonum= xy-wf piswap-wf)))))))

(defun fourier-test-program (type)
"Generate a test program for the QFT algorithm for two qubits. The types are as follows:
Expand Down

0 comments on commit c7d1b15

Please sign in to comment.