mimiqcircuits.operations.gates.standard.cu

Controlled-U gate.

Classes

GateCU([num_controls, operation])

Two qubit controlled-GateU gate.

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

Bases: Control

Two qubit controlled-GateU gate.

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

Matrix Representation

\[\begin{split}\operatorname{CU}(\theta, \phi, \lambda, \gamma) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\gamma} \cos\left(\frac{\theta}{2}\right) & -e^{i\gamma} e^{i\lambda}\sin\left(\frac{\theta}{2}\right) \\ 0 & 0 & e^{i\gamma} \mathrm{e}^{i\phi}\sin\left(\frac{\theta}{2}\right) & e^{i\gamma} \mathrm{e}^{i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) \end{pmatrix}\end{split}\]
Parameters:
  • theta – Euler angle \(\theta\) in radians.

  • phi – Euler angle \(\phi\) in radians.

  • lmbda – Euler angle \(\lambda\) in radians.

  • gamma – Phase \(\gamma\) in radians. It multiplies the target block only, so unlike the global phase of GateU it is observable once controlled. Defaults to 0.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta, phi, lmbda, gamma = symbols('theta phi lambda gamma')
>>> GateCU(theta, phi, lmbda, gamma), GateCU(theta, phi, lmbda, gamma).num_controls, GateCU(theta, phi, lmbda, gamma).num_targets, GateCU(theta, phi, lmbda, gamma).num_qubits
(CU(theta, phi, lambda, gamma), 1, 1, 2)
>>> GateCU(theta, phi, lmbda, gamma).matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, exp(I*gamma)*cos((1/2)*theta), -exp(I*(gamma + lambda))*sin((1/2)*theta)]
[0, 0, exp(I*(gamma + phi))*sin((1/2)*theta), exp(I*(gamma + lambda + phi))*cos((1/2)*theta)]

>>> c = Circuit().push(GateCU(theta, phi, lmbda, gamma), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── CU(theta, phi, lambda, gamma) @ q[0], q[1]

>>> GateCU(theta, phi, lmbda, gamma).power(2), GateCU(theta, phi, lmbda, gamma).inverse()
(C(U(theta, phi, lambda, gamma)**2), CU(-theta, -lambda, -phi, -gamma))
>>> GateCU(theta, phi, lmbda, gamma).decompose()
2-qubit circuit with 7 instructions:
├── P(gamma) @ q[0]
├── P((1/2)*(lambda + phi)) @ q[0]
├── P((1/2)*(lambda - phi)) @ q[1]
├── CX @ q[0], q[1]
├── U((-1/2)*theta, 0, (-1/2)*(lambda + phi), 0.0) @ q[1]
├── CX @ q[0], q[1]
└── U((1/2)*theta, phi, 0, 0.0) @ q[1]
__init__(theta_or_num_controls, phi_or_operation=None, lmbda=None, gamma=None, num_controls=None, operation=None)[source]

Initialize a CU gate.

Called directly as GateCU(theta, phi, lmbda, gamma). The signature also accepts GateCU(1, GateU(...)), the form Control uses to build its canonical subclass.

Parameters:
  • theta_or_num_controls – Euler angle \(\theta\) in radians, or the number of controls (always 1) in the Control form.

  • phi_or_operation – Euler angle \(\phi\) in radians, or the GateU whose angles are taken in the Control form.

  • lmbda – Euler angle \(\lambda\) in radians.

  • gamma – Phase \(\gamma\) in radians. Defaults to 0.

  • num_controls – Unused.

  • operation – Unused.