Skip to content

Commit

Permalink
compile CONTROLLED R[XYZ] allowing symbolic parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
stylewarning committed Jul 19, 2022
1 parent 36f6ffb commit 121a26d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/compilers/translators.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,31 @@ Note that if (= START-NODE TARGET-NODE) then (list START-NODE) is returned."
(define-compiler C-SWAP-to-CSWAP
((_ (#.(controlled-operator (named-operator "SWAP")) () p q r)))
(inst "CSWAP" () p q r))

(define-compiler C-RX-to-CZ-RX
((_ (#.(controlled-operator (named-operator "RX")) (theta) p q)))
(inst "CZ" () p q)
(inst "RX" (list (param-* -1/2 theta)) q)
(inst "CZ" () p q)
(inst "RX" (list (param-* 1/2 theta)) q))

(define-compiler C-RY-to-CZ-RY
((_ (#.(controlled-operator (named-operator "RY")) (theta) p q)))
(inst "CZ" () p q)
(inst "RY" (list (param-* -1/2 theta)) q)
(inst "CZ" () p q)
(inst "RY" (list (param-* 1/2 theta)) q))

(define-compiler C-RY-to-CNOT-RY
((_ (#.(controlled-operator (named-operator "RY")) (theta) p q)))
(inst "CNOT" () p q)
(inst "RY" (list (param-* -1/2 theta)) q)
(inst "CNOT" () p q)
(inst "RY" (list (param-* 1/2 theta)) q))

(define-compiler C-RZ-to-CNOT-RZ
((_ (#.(controlled-operator (named-operator "RZ")) (theta) p q)))
(inst "CNOT" () p q)
(inst "RZ" (list (param-* -1/2 theta)) q)
(inst "CNOT" () p q)
(inst "RZ" (list (param-* 1/2 theta)) q))

0 comments on commit 121a26d

Please sign in to comment.