Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpType.CnRx and OpType.CnRz #1405

Merged
merged 11 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pytket/binders/circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,18 @@ PYBIND11_MODULE(circuit, m) {
":math:`(\\alpha, \\beta) \\mapsto \\mathrm{PhasedX}(\\alpha, \\beta)"
"^{\\otimes n}` (n-qubit gate composed of identical PhasedX in "
"parallel.")
.value(
"CnRx", OpType::CnRx,
":math:`(\\alpha)` := n-controlled "
":math:`\\mathrm{Rx}(\\alpha)` gate.")
.value(
"CnRy", OpType::CnRy,
":math:`(\\alpha)` := n-controlled "
":math:`\\mathrm{Ry}(\\alpha)` gate.")
.value(
"CnRz", OpType::CnRz,
":math:`(\\alpha)` := n-controlled "
":math:`\\mathrm{Rz}(\\alpha)` gate.")
.value("CnX", OpType::CnX, "n-controlled X gate.")
.value("CnY", OpType::CnY, "n-controlled Y gate.")
.value("CnZ", OpType::CnZ, "n-controlled Z gate.")
Expand Down
2 changes: 1 addition & 1 deletion pytket/binders/passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ PYBIND11_MODULE(passes, m) {
m.def(
"DecomposeArbitrarilyControlledGates",
&DecomposeArbitrarilyControlledGates,
"Decomposes CCX, CnX, CnY, CnZ, and CnRy gates into "
"Decomposes CCX, CnX, CnY, CnZ, CnRy, CnRz and CnRx gates into "
"CX and single-qubit gates.");
m.def(
"DecomposeBoxes", &DecomposeBoxes,
Expand Down
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.3.0@tket/stable")
self.requires("tket/1.3.1@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.4@tket/stable")
Expand Down
4 changes: 4 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
Unreleased
----------

Features:

* Add ``OpType.CnRx`` and ``OpType.CnRz``.

Fixes:

* Allow barriers when dagger or transpose a circuit.
Expand Down
60 changes: 33 additions & 27 deletions pytket/pytket/_tket/circuit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3250,8 +3250,12 @@ class OpType:

NPhasedX : :math:`(\\alpha, \\beta) \\mapsto \\mathrm{PhasedX}(\\alpha, \\beta)^{\\otimes n}` (n-qubit gate composed of identical PhasedX in parallel.

CnRx : :math:`(\\alpha)` := n-controlled :math:`\\mathrm{Rx}(\\alpha)` gate.

CnRy : :math:`(\\alpha)` := n-controlled :math:`\\mathrm{Ry}(\\alpha)` gate.

CnRz : :math:`(\\alpha)` := n-controlled :math:`\\mathrm{Rz}(\\alpha)` gate.

CnX : n-controlled X gate.

CnY : n-controlled Y gate.
Expand Down Expand Up @@ -3319,22 +3323,24 @@ class OpType:
CX: typing.ClassVar[OpType] # value = <OpType.CX: 45>
CY: typing.ClassVar[OpType] # value = <OpType.CY: 46>
CZ: typing.ClassVar[OpType] # value = <OpType.CZ: 47>
CircBox: typing.ClassVar[OpType] # value = <OpType.CircBox: 87>
ClassicalExpBox: typing.ClassVar[OpType] # value = <OpType.ClassicalExpBox: 107>
CircBox: typing.ClassVar[OpType] # value = <OpType.CircBox: 89>
ClassicalExpBox: typing.ClassVar[OpType] # value = <OpType.ClassicalExpBox: 109>
ClassicalTransform: typing.ClassVar[OpType] # value = <OpType.ClassicalTransform: 13>
CnRx: typing.ClassVar[OpType] # value = <OpType.CnRx: 84>
CnRy: typing.ClassVar[OpType] # value = <OpType.CnRy: 83>
CnX: typing.ClassVar[OpType] # value = <OpType.CnX: 84>
CnY: typing.ClassVar[OpType] # value = <OpType.CnY: 86>
CnZ: typing.ClassVar[OpType] # value = <OpType.CnZ: 85>
Conditional: typing.ClassVar[OpType] # value = <OpType.Conditional: 108>
ConjugationBox: typing.ClassVar[OpType] # value = <OpType.ConjugationBox: 106>
CnRz: typing.ClassVar[OpType] # value = <OpType.CnRz: 85>
CnX: typing.ClassVar[OpType] # value = <OpType.CnX: 86>
CnY: typing.ClassVar[OpType] # value = <OpType.CnY: 88>
CnZ: typing.ClassVar[OpType] # value = <OpType.CnZ: 87>
Conditional: typing.ClassVar[OpType] # value = <OpType.Conditional: 110>
ConjugationBox: typing.ClassVar[OpType] # value = <OpType.ConjugationBox: 108>
CopyBits: typing.ClassVar[OpType] # value = <OpType.CopyBits: 16>
CustomGate: typing.ClassVar[OpType] # value = <OpType.CustomGate: 97>
DiagonalBox: typing.ClassVar[OpType] # value = <OpType.DiagonalBox: 105>
DummyBox: typing.ClassVar[OpType] # value = <OpType.DummyBox: 113>
CustomGate: typing.ClassVar[OpType] # value = <OpType.CustomGate: 99>
DiagonalBox: typing.ClassVar[OpType] # value = <OpType.DiagonalBox: 107>
DummyBox: typing.ClassVar[OpType] # value = <OpType.DummyBox: 115>
ECR: typing.ClassVar[OpType] # value = <OpType.ECR: 69>
ESWAP: typing.ClassVar[OpType] # value = <OpType.ESWAP: 78>
ExpBox: typing.ClassVar[OpType] # value = <OpType.ExpBox: 91>
ExpBox: typing.ClassVar[OpType] # value = <OpType.ExpBox: 93>
ExplicitModifier: typing.ClassVar[OpType] # value = <OpType.ExplicitModifier: 19>
ExplicitPredicate: typing.ClassVar[OpType] # value = <OpType.ExplicitPredicate: 18>
FSim: typing.ClassVar[OpType] # value = <OpType.FSim: 79>
Expand All @@ -3347,19 +3353,19 @@ class OpType:
Label: typing.ClassVar[OpType] # value = <OpType.Label: 9>
Measure: typing.ClassVar[OpType] # value = <OpType.Measure: 66>
MultiBit: typing.ClassVar[OpType] # value = <OpType.MultiBit: 20>
MultiplexedRotationBox: typing.ClassVar[OpType] # value = <OpType.MultiplexedRotationBox: 101>
MultiplexedTensoredU2Box: typing.ClassVar[OpType] # value = <OpType.MultiplexedTensoredU2Box: 103>
MultiplexedU2Box: typing.ClassVar[OpType] # value = <OpType.MultiplexedU2Box: 102>
MultiplexorBox: typing.ClassVar[OpType] # value = <OpType.MultiplexorBox: 100>
MultiplexedRotationBox: typing.ClassVar[OpType] # value = <OpType.MultiplexedRotationBox: 103>
MultiplexedTensoredU2Box: typing.ClassVar[OpType] # value = <OpType.MultiplexedTensoredU2Box: 105>
MultiplexedU2Box: typing.ClassVar[OpType] # value = <OpType.MultiplexedU2Box: 104>
MultiplexorBox: typing.ClassVar[OpType] # value = <OpType.MultiplexorBox: 102>
NPhasedX: typing.ClassVar[OpType] # value = <OpType.NPhasedX: 72>
PauliExpBox: typing.ClassVar[OpType] # value = <OpType.PauliExpBox: 92>
PauliExpCommutingSetBox: typing.ClassVar[OpType] # value = <OpType.PauliExpCommutingSetBox: 94>
PauliExpPairBox: typing.ClassVar[OpType] # value = <OpType.PauliExpPairBox: 93>
PauliExpBox: typing.ClassVar[OpType] # value = <OpType.PauliExpBox: 94>
PauliExpCommutingSetBox: typing.ClassVar[OpType] # value = <OpType.PauliExpCommutingSetBox: 96>
PauliExpPairBox: typing.ClassVar[OpType] # value = <OpType.PauliExpPairBox: 95>
Phase: typing.ClassVar[OpType] # value = <OpType.Phase: 21>
PhasePolyBox: typing.ClassVar[OpType] # value = <OpType.PhasePolyBox: 98>
PhasePolyBox: typing.ClassVar[OpType] # value = <OpType.PhasePolyBox: 100>
PhasedISWAP: typing.ClassVar[OpType] # value = <OpType.PhasedISWAP: 82>
PhasedX: typing.ClassVar[OpType] # value = <OpType.PhasedX: 71>
QControlBox: typing.ClassVar[OpType] # value = <OpType.QControlBox: 99>
QControlBox: typing.ClassVar[OpType] # value = <OpType.QControlBox: 101>
RangePredicate: typing.ClassVar[OpType] # value = <OpType.RangePredicate: 17>
Reset: typing.ClassVar[OpType] # value = <OpType.Reset: 68>
Rx: typing.ClassVar[OpType] # value = <OpType.Rx: 34>
Expand All @@ -3371,21 +3377,21 @@ class OpType:
SXdg: typing.ClassVar[OpType] # value = <OpType.SXdg: 32>
Sdg: typing.ClassVar[OpType] # value = <OpType.Sdg: 26>
SetBits: typing.ClassVar[OpType] # value = <OpType.SetBits: 15>
StatePreparationBox: typing.ClassVar[OpType] # value = <OpType.StatePreparationBox: 104>
StatePreparationBox: typing.ClassVar[OpType] # value = <OpType.StatePreparationBox: 106>
Stop: typing.ClassVar[OpType] # value = <OpType.Stop: 12>
Sycamore: typing.ClassVar[OpType] # value = <OpType.Sycamore: 80>
T: typing.ClassVar[OpType] # value = <OpType.T: 27>
TK1: typing.ClassVar[OpType] # value = <OpType.TK1: 43>
TK2: typing.ClassVar[OpType] # value = <OpType.TK2: 44>
Tdg: typing.ClassVar[OpType] # value = <OpType.Tdg: 28>
TermSequenceBox: typing.ClassVar[OpType] # value = <OpType.TermSequenceBox: 95>
ToffoliBox: typing.ClassVar[OpType] # value = <OpType.ToffoliBox: 111>
TermSequenceBox: typing.ClassVar[OpType] # value = <OpType.TermSequenceBox: 97>
ToffoliBox: typing.ClassVar[OpType] # value = <OpType.ToffoliBox: 113>
U1: typing.ClassVar[OpType] # value = <OpType.U1: 39>
U2: typing.ClassVar[OpType] # value = <OpType.U2: 38>
U3: typing.ClassVar[OpType] # value = <OpType.U3: 37>
Unitary1qBox: typing.ClassVar[OpType] # value = <OpType.Unitary1qBox: 88>
Unitary2qBox: typing.ClassVar[OpType] # value = <OpType.Unitary2qBox: 89>
Unitary3qBox: typing.ClassVar[OpType] # value = <OpType.Unitary3qBox: 90>
Unitary1qBox: typing.ClassVar[OpType] # value = <OpType.Unitary1qBox: 90>
Unitary2qBox: typing.ClassVar[OpType] # value = <OpType.Unitary2qBox: 91>
Unitary3qBox: typing.ClassVar[OpType] # value = <OpType.Unitary3qBox: 92>
V: typing.ClassVar[OpType] # value = <OpType.V: 29>
Vdg: typing.ClassVar[OpType] # value = <OpType.Vdg: 30>
WASM: typing.ClassVar[OpType] # value = <OpType.WASM: 14>
Expand All @@ -3397,7 +3403,7 @@ class OpType:
Z: typing.ClassVar[OpType] # value = <OpType.Z: 22>
ZZMax: typing.ClassVar[OpType] # value = <OpType.ZZMax: 73>
ZZPhase: typing.ClassVar[OpType] # value = <OpType.ZZPhase: 76>
__members__: typing.ClassVar[dict[str, OpType]] # value = {'Phase': <OpType.Phase: 21>, 'Z': <OpType.Z: 22>, 'X': <OpType.X: 23>, 'Y': <OpType.Y: 24>, 'S': <OpType.S: 25>, 'Sdg': <OpType.Sdg: 26>, 'T': <OpType.T: 27>, 'Tdg': <OpType.Tdg: 28>, 'V': <OpType.V: 29>, 'Vdg': <OpType.Vdg: 30>, 'SX': <OpType.SX: 31>, 'SXdg': <OpType.SXdg: 32>, 'H': <OpType.H: 33>, 'Rx': <OpType.Rx: 34>, 'Ry': <OpType.Ry: 35>, 'Rz': <OpType.Rz: 36>, 'U1': <OpType.U1: 39>, 'U2': <OpType.U2: 38>, 'U3': <OpType.U3: 37>, 'GPI': <OpType.GPI: 40>, 'GPI2': <OpType.GPI2: 41>, 'AAMS': <OpType.AAMS: 42>, 'TK1': <OpType.TK1: 43>, 'TK2': <OpType.TK2: 44>, 'CX': <OpType.CX: 45>, 'CY': <OpType.CY: 46>, 'CZ': <OpType.CZ: 47>, 'CH': <OpType.CH: 48>, 'CV': <OpType.CV: 49>, 'CVdg': <OpType.CVdg: 50>, 'CSX': <OpType.CSX: 51>, 'CSXdg': <OpType.CSXdg: 52>, 'CS': <OpType.CS: 53>, 'CSdg': <OpType.CSdg: 54>, 'CRz': <OpType.CRz: 55>, 'CRx': <OpType.CRx: 56>, 'CRy': <OpType.CRy: 57>, 'CU1': <OpType.CU1: 58>, 'CU3': <OpType.CU3: 59>, 'CCX': <OpType.CCX: 61>, 'ECR': <OpType.ECR: 69>, 'SWAP': <OpType.SWAP: 62>, 'CSWAP': <OpType.CSWAP: 63>, 'noop': <OpType.noop: 65>, 'Barrier': <OpType.Barrier: 8>, 'Label': <OpType.Label: 9>, 'Branch': <OpType.Branch: 10>, 'Goto': <OpType.Goto: 11>, 'Stop': <OpType.Stop: 12>, 'BRIDGE': <OpType.BRIDGE: 64>, 'Measure': <OpType.Measure: 66>, 'Reset': <OpType.Reset: 68>, 'CircBox': <OpType.CircBox: 87>, 'PhasePolyBox': <OpType.PhasePolyBox: 98>, 'Unitary1qBox': <OpType.Unitary1qBox: 88>, 'Unitary2qBox': <OpType.Unitary2qBox: 89>, 'Unitary3qBox': <OpType.Unitary3qBox: 90>, 'ExpBox': <OpType.ExpBox: 91>, 'PauliExpBox': <OpType.PauliExpBox: 92>, 'PauliExpPairBox': <OpType.PauliExpPairBox: 93>, 'PauliExpCommutingSetBox': <OpType.PauliExpCommutingSetBox: 94>, 'TermSequenceBox': <OpType.TermSequenceBox: 95>, 'QControlBox': <OpType.QControlBox: 99>, 'ToffoliBox': <OpType.ToffoliBox: 111>, 'ConjugationBox': <OpType.ConjugationBox: 106>, 'DummyBox': <OpType.DummyBox: 113>, 'CustomGate': <OpType.CustomGate: 97>, 'Conditional': <OpType.Conditional: 108>, 'ISWAP': <OpType.ISWAP: 70>, 'PhasedISWAP': <OpType.PhasedISWAP: 82>, 'XXPhase': <OpType.XXPhase: 74>, 'YYPhase': <OpType.YYPhase: 75>, 'ZZPhase': <OpType.ZZPhase: 76>, 'XXPhase3': <OpType.XXPhase3: 77>, 'PhasedX': <OpType.PhasedX: 71>, 'NPhasedX': <OpType.NPhasedX: 72>, 'CnRy': <OpType.CnRy: 83>, 'CnX': <OpType.CnX: 84>, 'CnY': <OpType.CnY: 86>, 'CnZ': <OpType.CnZ: 85>, 'ZZMax': <OpType.ZZMax: 73>, 'ESWAP': <OpType.ESWAP: 78>, 'FSim': <OpType.FSim: 79>, 'Sycamore': <OpType.Sycamore: 80>, 'ISWAPMax': <OpType.ISWAPMax: 81>, 'ClassicalTransform': <OpType.ClassicalTransform: 13>, 'WASM': <OpType.WASM: 14>, 'SetBits': <OpType.SetBits: 15>, 'CopyBits': <OpType.CopyBits: 16>, 'RangePredicate': <OpType.RangePredicate: 17>, 'ExplicitPredicate': <OpType.ExplicitPredicate: 18>, 'ExplicitModifier': <OpType.ExplicitModifier: 19>, 'MultiBit': <OpType.MultiBit: 20>, 'ClassicalExpBox': <OpType.ClassicalExpBox: 107>, 'MultiplexorBox': <OpType.MultiplexorBox: 100>, 'MultiplexedRotationBox': <OpType.MultiplexedRotationBox: 101>, 'MultiplexedU2Box': <OpType.MultiplexedU2Box: 102>, 'MultiplexedTensoredU2Box': <OpType.MultiplexedTensoredU2Box: 103>, 'StatePreparationBox': <OpType.StatePreparationBox: 104>, 'DiagonalBox': <OpType.DiagonalBox: 105>}
__members__: typing.ClassVar[dict[str, OpType]] # value = {'Phase': <OpType.Phase: 21>, 'Z': <OpType.Z: 22>, 'X': <OpType.X: 23>, 'Y': <OpType.Y: 24>, 'S': <OpType.S: 25>, 'Sdg': <OpType.Sdg: 26>, 'T': <OpType.T: 27>, 'Tdg': <OpType.Tdg: 28>, 'V': <OpType.V: 29>, 'Vdg': <OpType.Vdg: 30>, 'SX': <OpType.SX: 31>, 'SXdg': <OpType.SXdg: 32>, 'H': <OpType.H: 33>, 'Rx': <OpType.Rx: 34>, 'Ry': <OpType.Ry: 35>, 'Rz': <OpType.Rz: 36>, 'U1': <OpType.U1: 39>, 'U2': <OpType.U2: 38>, 'U3': <OpType.U3: 37>, 'GPI': <OpType.GPI: 40>, 'GPI2': <OpType.GPI2: 41>, 'AAMS': <OpType.AAMS: 42>, 'TK1': <OpType.TK1: 43>, 'TK2': <OpType.TK2: 44>, 'CX': <OpType.CX: 45>, 'CY': <OpType.CY: 46>, 'CZ': <OpType.CZ: 47>, 'CH': <OpType.CH: 48>, 'CV': <OpType.CV: 49>, 'CVdg': <OpType.CVdg: 50>, 'CSX': <OpType.CSX: 51>, 'CSXdg': <OpType.CSXdg: 52>, 'CS': <OpType.CS: 53>, 'CSdg': <OpType.CSdg: 54>, 'CRz': <OpType.CRz: 55>, 'CRx': <OpType.CRx: 56>, 'CRy': <OpType.CRy: 57>, 'CU1': <OpType.CU1: 58>, 'CU3': <OpType.CU3: 59>, 'CCX': <OpType.CCX: 61>, 'ECR': <OpType.ECR: 69>, 'SWAP': <OpType.SWAP: 62>, 'CSWAP': <OpType.CSWAP: 63>, 'noop': <OpType.noop: 65>, 'Barrier': <OpType.Barrier: 8>, 'Label': <OpType.Label: 9>, 'Branch': <OpType.Branch: 10>, 'Goto': <OpType.Goto: 11>, 'Stop': <OpType.Stop: 12>, 'BRIDGE': <OpType.BRIDGE: 64>, 'Measure': <OpType.Measure: 66>, 'Reset': <OpType.Reset: 68>, 'CircBox': <OpType.CircBox: 89>, 'PhasePolyBox': <OpType.PhasePolyBox: 100>, 'Unitary1qBox': <OpType.Unitary1qBox: 90>, 'Unitary2qBox': <OpType.Unitary2qBox: 91>, 'Unitary3qBox': <OpType.Unitary3qBox: 92>, 'ExpBox': <OpType.ExpBox: 93>, 'PauliExpBox': <OpType.PauliExpBox: 94>, 'PauliExpPairBox': <OpType.PauliExpPairBox: 95>, 'PauliExpCommutingSetBox': <OpType.PauliExpCommutingSetBox: 96>, 'TermSequenceBox': <OpType.TermSequenceBox: 97>, 'QControlBox': <OpType.QControlBox: 101>, 'ToffoliBox': <OpType.ToffoliBox: 113>, 'ConjugationBox': <OpType.ConjugationBox: 108>, 'DummyBox': <OpType.DummyBox: 115>, 'CustomGate': <OpType.CustomGate: 99>, 'Conditional': <OpType.Conditional: 110>, 'ISWAP': <OpType.ISWAP: 70>, 'PhasedISWAP': <OpType.PhasedISWAP: 82>, 'XXPhase': <OpType.XXPhase: 74>, 'YYPhase': <OpType.YYPhase: 75>, 'ZZPhase': <OpType.ZZPhase: 76>, 'XXPhase3': <OpType.XXPhase3: 77>, 'PhasedX': <OpType.PhasedX: 71>, 'NPhasedX': <OpType.NPhasedX: 72>, 'CnRx': <OpType.CnRx: 84>, 'CnRy': <OpType.CnRy: 83>, 'CnRz': <OpType.CnRz: 85>, 'CnX': <OpType.CnX: 86>, 'CnY': <OpType.CnY: 88>, 'CnZ': <OpType.CnZ: 87>, 'ZZMax': <OpType.ZZMax: 73>, 'ESWAP': <OpType.ESWAP: 78>, 'FSim': <OpType.FSim: 79>, 'Sycamore': <OpType.Sycamore: 80>, 'ISWAPMax': <OpType.ISWAPMax: 81>, 'ClassicalTransform': <OpType.ClassicalTransform: 13>, 'WASM': <OpType.WASM: 14>, 'SetBits': <OpType.SetBits: 15>, 'CopyBits': <OpType.CopyBits: 16>, 'RangePredicate': <OpType.RangePredicate: 17>, 'ExplicitPredicate': <OpType.ExplicitPredicate: 18>, 'ExplicitModifier': <OpType.ExplicitModifier: 19>, 'MultiBit': <OpType.MultiBit: 20>, 'ClassicalExpBox': <OpType.ClassicalExpBox: 109>, 'MultiplexorBox': <OpType.MultiplexorBox: 102>, 'MultiplexedRotationBox': <OpType.MultiplexedRotationBox: 103>, 'MultiplexedU2Box': <OpType.MultiplexedU2Box: 104>, 'MultiplexedTensoredU2Box': <OpType.MultiplexedTensoredU2Box: 105>, 'StatePreparationBox': <OpType.StatePreparationBox: 106>, 'DiagonalBox': <OpType.DiagonalBox: 107>}
noop: typing.ClassVar[OpType] # value = <OpType.noop: 65>
@staticmethod
def from_name(arg0: str) -> OpType:
Expand Down
2 changes: 1 addition & 1 deletion pytket/pytket/_tket/passes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def CustomRoutingPass(arc: pytket._tket.architecture.Architecture, config: typin
"""
def DecomposeArbitrarilyControlledGates() -> BasePass:
"""
Decomposes CCX, CnX, CnY, CnZ, and CnRy gates into CX and single-qubit gates.
Decomposes CCX, CnX, CnY, CnZ, CnRy, CnRz and CnRx gates into CX and single-qubit gates.
"""
def DecomposeBoxes(excluded_types: set[pytket._tket.circuit.OpType] = set(), excluded_opgroups: set[str] = set()) -> BasePass:
"""
Expand Down
15 changes: 15 additions & 0 deletions pytket/tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,20 @@ def test_pickle_bit() -> None:
assert b == pickle.loads(pickle.dumps(b))


def test_cnrx_cnrz() -> None:
c1rx = Circuit(2)
c1rx.add_gate(OpType.CnRx, 0.3, [0, 1])
crx = Circuit(2)
crx.add_gate(OpType.CRx, 0.3, [0, 1])

c1rz = Circuit(2)
c1rz.add_gate(OpType.CnRz, 0.3, [0, 1])
crz = Circuit(2)
crz.add_gate(OpType.CRz, 0.3, [0, 1])

assert np.allclose(c1rz.get_unitary(), crz.get_unitary())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check c1rx == crx?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, yep will add back in!



if __name__ == "__main__":
test_circuit_gen()
test_symbolic_ops()
Expand All @@ -1551,3 +1565,4 @@ def test_pickle_bit() -> None:
test_multi_controlled_gates()
test_counting_n_qubit_gates()
test_pauliexp_pair_box_serialisation()
test_cnrx_cnrz()
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.3.0"
version = "1.3.1"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
4 changes: 4 additions & 0 deletions tket/include/tket/Circuit/CircPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ Circuit CnX_gray_decomp(unsigned n);

Circuit CnRy_normal_decomp(const Op_ptr op, unsigned arity);

Circuit CnRx_normal_decomp(const Op_ptr op, unsigned arity);

Circuit CnRz_normal_decomp(const Op_ptr op, unsigned arity);

/**
* @brief Given a 2x2 numerical unitary matrix U and the number of control
* qubits n return the decomposed CnU gate
Expand Down
4 changes: 4 additions & 0 deletions tket/include/tket/Gate/GateUnitaryMatrixImplementations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ struct GateUnitaryMatrixImplementations {
// to have a sparse version.
static Eigen::MatrixXcd CnRy(unsigned int number_of_qubits, double alpha);

static Eigen::MatrixXcd CnRx(unsigned int number_of_qubits, double alpha);

static Eigen::MatrixXcd CnRz(unsigned int number_of_qubits, double alpha);

static Eigen::MatrixXcd CnX(unsigned int number_of_qubits);

static Eigen::MatrixXcd CnZ(unsigned int number_of_qubits);
Expand Down
14 changes: 14 additions & 0 deletions tket/include/tket/OpType/OpType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,20 @@ enum class OpType {
*/
CnRy,

/**
* Multiply-controlled \ref OpType::Rz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Multiply-controlled \ref OpType::Rz
* Multiply-controlled \ref OpType::Rx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good spot, done

*
* The phase parameter is defined modulo \f$ 4 \f$.
*/
CnRx,

/**
* Multiply-controlled \ref OpType::Rx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Multiply-controlled \ref OpType::Rx
* Multiply-controlled \ref OpType::Rz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*
* The phase parameter is defined modulo \f$ 4 \f$.
*/
CnRz,

/**
* Multiply-controlled \ref OpType::X
*/
Expand Down
2 changes: 1 addition & 1 deletion tket/include/tket/Transformations/Decomposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Transform decomp_CCX();
Transform decomp_controlled_Rys();

// does not use ancillae
// Expects: CCX, CnX, CnY, CnZ, CnRy and any other gates
// Expects: CCX, CnX, CnY, CnZ, CnRy, CnRx, CnRz, and any other gates
// returns CX and single-qubit gate + any previous gates
Transform decomp_arbitrary_controlled_gates();

Expand Down
3 changes: 2 additions & 1 deletion tket/include/tket/Transformations/Replacement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Circuit CX_circ_from_multiq(const Op_ptr op);
Circuit CX_ZX_circ_from_op(const Op_ptr op);

/**
* Replace CnRy, CnX, CnZ, CnY with 2-qubit gates and single qubit gates
* Replace CnRy, CnRx, CnRz, CnX, CnZ, CnY with 2-qubit gates and single qubit
* gates
*
* @param op operation
* @param two_q_type whether rebase 2-q gates to CX or TK2
Expand Down
Loading
Loading