mimiqcircuits.operations.gates.standard.cphase

Controlled-Phase gate.

Classes

GateCP([num_controls, operation])

Two qubit Controlled-Phase gate.

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

Bases: Control

Two qubit Controlled-Phase gate.

By convention, the first qubit is the control and the second is the target.

Matrix Representation

\[\begin{split}\operatorname{CP}(\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\lambda} \end{pmatrix}\end{split}\]
Parameters:

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

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> lmbda = Symbol('lambda')
>>> GateCP(lmbda), GateCP(lmbda).num_controls, GateCP(lmbda).num_targets, GateCP(lmbda).num_qubits
(CP(lambda), 1, 1, 2)
>>> GateCP(lmbda).matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 1.0, 0]
[0, 0, 0, exp(I*lambda)]

>>> c = Circuit().push(GateCP(lmbda), 10, 11)
>>> c
12-qubit circuit with 1 instruction:
└── CP(lambda) @ q[10], q[11]

>>> GateCP(lmbda).power(2), GateCP(lmbda).inverse()
(CP(2*lambda), CP(-lambda))
>>> GateCP(lmbda).decompose()
2-qubit circuit with 5 instructions:
├── P((1/2)*lambda) @ q[0]
├── CX @ q[0], q[1]
├── P((-1/2)*lambda) @ q[1]
├── CX @ q[0], q[1]
└── P((1/2)*lambda) @ q[1]

See also

GateP, GateCCP

__init__(lmbda_or_num_controls, num_controls_or_operation=None, operation=None)[source]

Initialize a CP gate.

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

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

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

  • operation – Unused.