Skip to content

Commit

Permalink
Merge pull request #173 from dlyongemallo/rzz_pp
Browse files Browse the repository at this point in the history
Make `RZZ` a subclass of `ParityPhase`.
  • Loading branch information
jvdwetering authored Oct 22, 2023
2 parents 4e7eb4a + 6d1fa44 commit 5beb9bc
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions pyzx/circuit/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,24 +732,6 @@ def to_graph(self, g, q_mapper, c_mapper):
for gate in self.to_basic_gates():
gate.to_graph(g, q_mapper, c_mapper)

class RZZ(Gate):
name = 'RZZ'
qasm_name = 'rzz'
print_phase = True
def __init__(self, control: int, target: int, phase: FractionLike) -> None:
self.target = target
self.control = control
self.phase = phase

def to_basic_gates(self):
return [CNOT(control=self.control,target=self.target),
ZPhase(self.target,phase=self.phase),
CNOT(control=self.control,target=self.target)]

def to_graph(self, g, q_mapper, c_mapper):
for gate in self.to_basic_gates():
gate.to_graph(g, q_mapper, c_mapper)

class CPhase(CRZ):
name = 'CPhase'
qasm_name = 'cp'
Expand Down Expand Up @@ -827,6 +809,16 @@ def tcount(self):
return 1 if self.phase.denominator > 2 else 0


class RZZ(ParityPhase):
name = 'RZZ'
qasm_name = 'rzz'
def __init__(self, control: int, target: int, phase: FractionLike) -> None:
self.control = control
self.target = target
self.targets = (control, target)
self.phase = phase


class FSim(Gate):
name = 'FSim'
qsim_name = 'fs'
Expand Down

0 comments on commit 5beb9bc

Please sign in to comment.