mimiqcircuits.operations.gates.standard.cnp

Controlled-Controlled-Phase (CCP) gate.

Classes

GateCCP([num_controls, operation])

Three qubit Controlled-Controlled-Phase gate.

class GateCCP(num_controls=None, operation=None, *args, **kwargs)[source]

Bases: Control

Three qubit Controlled-Controlled-Phase gate.

By convention, the first two qubits are the controls and the third is the target.

Matrix Representation

\[\operatorname{CCP}(\lambda) = \operatorname{diag}(1, 1, 1, 1, 1, 1, 1, e^{i\lambda})\]
Parameters:

lmbda – Phase angle \(\lambda\) in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> lmbda = Symbol('lmbda')
>>> GateCCP(lmbda), GateCCP(lmbda).num_controls, GateCCP(lmbda).num_targets, GateCCP(lmbda).num_qubits
(C₂P(lmbda), 2, 1, 3)
>>> GateCCP(lmbda).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, 1.0, 0, 0]
[0, 0, 0, 0, 0, 0, 1.0, 0]
[0, 0, 0, 0, 0, 0, 0, exp(I*lmbda)]

>>> c = Circuit().push(GateCCP(lmbda), 0, 1, 2)
>>> c
3-qubit circuit with 1 instruction:
└── C₂P(lmbda) @ q[0:1], q[2]

>>> GateCCP(lmbda).power(2), GateCCP(lmbda).inverse()
(C₂P(2*lmbda), C₂P(-lmbda))
>>> GateCCP(lmbda).decompose()
3-qubit circuit with 5 instructions:
├── CP((1/2)*lmbda) @ q[1], q[2]
├── CX @ q[0], q[1]
├── CP((-1/2)*lmbda) @ q[1], q[2]
├── CX @ q[0], q[1]
└── CP((1/2)*lmbda) @ q[0], q[2]
__init__(lmbda_or_num_controls, num_controls_or_operation=None, operation=None)[source]

Initialize a CCP gate.

Called directly as GateCCP(lmbda). The signature also accepts GateCCP(2, GateP(lmbda)) and GateCCP(1, GateCP(lmbda)), the forms Control uses to build its canonical subclass.

Parameters:
  • lmbda_or_num_controls – Phase angle in radians, or the number of controls in the Control form.

  • num_controls_or_operation – Unused when called directly, or the GateP (or GateCP) whose angle is taken in the Control form.

  • operation – Unused.