Skip to content

Commit

Permalink
Fix CRz and CRx gate conversion (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-richie-y committed Jan 25, 2024
1 parent c839adf commit b7fdf6e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions discopy/quantum/zx.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ def gate2zx(box):
if isinstance(box, (Rz, Rx)):
return (Z if isinstance(box, Rz) else X)(1, 1, box.phase)
if isinstance(box, Controlled) and box.name.startswith('CRz'):
return Z(1, 2) @ Z(1, 2, box.phase)\
>> Id(1) @ (X(2, 1) >> Z(1, 0, -box.phase)) @ Id(1)
return Z(1, 2) @ Z(1, 2, box.phase / 2)\
>> Id(1) @ (X(2, 1) >> Z(1, 0, -box.phase / 2)) @ Id(1)
if isinstance(box, Controlled) and box.name.startswith('CRx'):
return X(1, 2) @ X(1, 2, box.phase)\
>> Id(1) @ (Z(2, 1) >> X(1, 0, -box.phase)) @ Id(1)
return X(1, 2) @ X(1, 2, box.phase / 2)\
>> Id(1) @ (Z(2, 1) >> X(1, 0, -box.phase / 2)) @ Id(1)
if isinstance(box, quantum.CU1):
return Z(1, 2, box.phase) @ Z(1, 2, box.phase)\
>> Id(1) @ (X(2, 1) >> Z(1, 0, -box.phase)) @ Id(1)
Expand Down

0 comments on commit b7fdf6e

Please sign in to comment.