mimiqcircuits.operations.gates.standard.crotations¶
Controlled-Rotation (CRX, CRY, CRZ) gates.
Classes
|
Two qubit Controlled-RX gate. |
|
Two qubit Controlled-RY gate. |
|
Two qubit Controlled-RZ gate. |
- class mimiqcircuits.operations.gates.standard.crotations.GateCRX(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlTwo qubit Controlled-RX gate.
By convention, the first qubit is the control and the second is the target
See Also
GateRX,GateCRY,GateCRZMatrix representation:
\[\begin{split}\operatorname{CRX}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ 0 & 0 & -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\end{split}\]- Parameters:
theta – The rotation angle in radians.
Examples
>>> from mimiqcircuits import * >>> from symengine import * >>> theta = Symbol('theta') >>> GateCRX(theta), GateCRX(theta).num_controls, GateCRX(theta).num_targets, GateCRX(theta).num_qubits (CRX(theta), 1, 1, 2) >>> GateCRX(theta).matrix() [1.0, 0, 0, 0] [0, 1.0, 0, 0] [0, 0, cos((1/2)*theta), -I*sin((1/2)*theta)] [0, 0, -I*sin((1/2)*theta), cos((1/2)*theta)] >>> c = Circuit().push(GateCRX(theta), 0, 1) >>> c 2-qubit circuit with 1 instruction: └── CRX(theta) @ q[0], q[1] >>> GateCRX(theta).power(2), GateCRX(theta).inverse() (CRX(2*theta), CRX(-theta)) >>> GateCRX(theta).decompose() 2-qubit circuit with 5 instructions: ├── P((1/2)*pi) @ q[1] ├── CX @ q[0], q[1] ├── U((-1/2)*theta, 0, 0, 0.0) @ q[1] ├── CX @ q[0], q[1] └── U((1/2)*theta, (-1/2)*pi, 0, 0.0) @ q[1]
- __init__(theta_or_num_controls, num_controls_or_operation=None, operation=None)[source]¶
Initialize a CRX gate.
- Parameters:
theta_or_num_controls – The rotation angle in radians when called directly, or num_controls when called from Control’s canonical creation.
num_controls_or_operation – Ignored when called directly, or the GateRX operation when called from Control’s canonical creation.
operation – Ignored (for compatibility).
- class mimiqcircuits.operations.gates.standard.crotations.GateCRY(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlTwo qubit Controlled-RY gate.
By convention, the first qubit is the control and the second is the target
See Also
GateRY,GateCRX,GateCRZMatrix representation:
\[\begin{split}\operatorname{CRY}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ 0 & 0 & \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\end{split}\]- Parameters:
theta – The rotation angle in radians.
Examples
>>> from mimiqcircuits import * >>> from symengine import * >>> theta = Symbol('theta') >>> GateCRY(theta), GateCRY(theta).num_controls, GateCRY(theta).num_targets, GateCRY(theta).num_qubits (CRY(theta), 1, 1, 2) >>> GateCRY(theta).matrix() [1.0, 0, 0, 0] [0, 1.0, 0, 0] [0, 0, cos((1/2)*theta), -sin((1/2)*theta)] [0, 0, sin((1/2)*theta), cos((1/2)*theta)] >>> c = Circuit().push(GateCRY(theta), 0, 1) >>> c 2-qubit circuit with 1 instruction: └── CRY(theta) @ q[0], q[1] >>> GateCRY(theta).power(2), GateCRY(theta).inverse() (CRY(2*theta), CRY(-theta)) >>> GateCRY(theta).decompose() 2-qubit circuit with 4 instructions: ├── RY((1/2)*theta) @ q[1] ├── CX @ q[0], q[1] ├── RY((-1/2)*theta) @ q[1] └── CX @ q[0], q[1]
- __init__(theta_or_num_controls, num_controls_or_operation=None, operation=None)[source]¶
Initialize a CRY gate.
- Parameters:
theta_or_num_controls – The rotation angle in radians when called directly, or num_controls when called from Control’s canonical creation.
num_controls_or_operation – Ignored when called directly, or the GateRY operation when called from Control’s canonical creation.
operation – Ignored (for compatibility).
- class mimiqcircuits.operations.gates.standard.crotations.GateCRZ(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlTwo qubit Controlled-RZ gate.
By convention, the first qubit is the control and the second is the target
See Also
GateRZ,GateCRX,GateCRYMatrix representation:
\[\begin{split}\operatorname{CRZ}(\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\frac{\lambda}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\lambda}{2}} \end{pmatrix}\end{split}\]- Parameters:
lmbda – The rotation angle in radians.
Examples
>>> from mimiqcircuits import * >>> from symengine import * >>> lmbda = Symbol('lambda') >>> GateCRZ(lmbda), GateCRZ(lmbda).num_controls, GateCRZ(lmbda).num_targets, GateCRZ(lmbda).num_qubits (CRZ(lambda), 1, 1, 2) >>> GateCRZ(lmbda).matrix() [1.0, 0, 0, 0] [0, 1.0, 0, 0] [0, 0, exp(-1/2*I*lambda), 0] [0, 0, 0, exp(1/2*I*lambda)] >>> c = Circuit().push(GateCRZ(lmbda), 0, 1) >>> c 2-qubit circuit with 1 instruction: └── CRZ(lambda) @ q[0], q[1] >>> GateCRZ(lmbda).power(2), GateCRZ(lmbda).inverse() (CRZ(2*lambda), CRZ(-lambda)) >>> GateCRZ(lmbda).decompose() 2-qubit circuit with 4 instructions: ├── RZ((1/2)*lambda) @ q[1] ├── CX @ q[0], q[1] ├── RZ((-1/2)*lambda) @ q[1] └── CX @ q[0], q[1]
- __init__(lmbda_or_num_controls, num_controls_or_operation=None, operation=None)[source]¶
Initialize a CRZ gate.
- Parameters:
lmbda_or_num_controls – The rotation angle in radians when called directly, or num_controls when called from Control’s canonical creation.
num_controls_or_operation – Ignored when called directly, or the GateRZ operation when called from Control’s canonical creation.
operation – Ignored (for compatibility).