mimiqcircuits.operations.gates.standard.cswap¶
Controlled-SWAP (Fredkin) gate.
Classes
|
Three qubit Controlled-SWAP gate. |
- class mimiqcircuits.operations.gates.standard.cswap.GateCSWAP(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlThree qubit Controlled-SWAP gate.
By convention, the first qubit is the control and last two are the targets.
Examples
>>> from mimiqcircuits import * >>> GateCSWAP(), GateCSWAP().num_controls, GateCSWAP().num_targets, GateCSWAP().num_qubits (CSWAP, 1, 2, 3) >>> GateCSWAP().matrix() [1.0, 0, 0, 0, 0, 0, 0, 0] [0, 1.0, 0, 0, 0, 0, 0, 0] [0, 0, 1.0, 0, 0, 0, 0, 0] [0, 0, 0, 1.0, 0, 0, 0, 0] [0, 0, 0, 0, 1.0, 0, 0, 0] [0, 0, 0, 0, 0, 0, 1.0, 0] [0, 0, 0, 0, 0, 1.0, 0, 0] [0, 0, 0, 0, 0, 0, 0, 1.0] >>> c = Circuit().push(GateCSWAP(), 0, 1, 2) >>> GateCSWAP().power(2), GateCSWAP().inverse() (C(⨷ ² ID), CSWAP) >>> c = Circuit().push(GateCSWAP(), 0, 1, 2) >>> c 3-qubit circuit with 1 instruction: └── CSWAP @ q[0], q[1:2] >>> GateCSWAP().power(2), GateCSWAP().inverse() (C(⨷ ² ID), CSWAP) >>> GateCSWAP().decompose() 3-qubit circuit with 3 instructions: ├── CX @ q[2], q[1] ├── C₂X @ q[0:1], q[2] └── CX @ q[2], q[1]