mimiqcircuits.operations.gates.standard.cu¶
Controlled-U gate.
Classes
|
Two qubit controlled unitary gate. |
- class mimiqcircuits.operations.gates.standard.cu.GateCU(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlTwo qubit controlled unitary gate.
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:
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.
- Parameters:
theta_or_num_controls – Euler angle 1 in radians when called directly, or num_controls when called from Control’s canonical creation.
phi_or_operation – Euler angle 2 in radians when called directly, or the GateU operation when called from Control’s canonical creation.
lmbda – Euler angle 3 in radians.
gamma – Global phase of the CU gate.
num_controls – Ignored (for compatibility).
operation – Ignored (for compatibility).