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 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.
Matrix 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 – Rotation angle in radians, numeric or symbolic.
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: ├── S @ 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.
Called directly as
GateCRX(theta). The signature also acceptsGateCRX(1, GateRX(theta)), the formControluses to build its canonical subclass.- Parameters:
theta_or_num_controls – Rotation angle in radians, or the number of controls (always 1) in the
Controlform.num_controls_or_operation – Unused when called directly, or the
GateRXwhose angle is taken in theControlform.operation – Unused.
- class 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.
Matrix 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 – Rotation angle in radians, numeric or symbolic.
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.
Called directly as
GateCRY(theta). The signature also acceptsGateCRY(1, GateRY(theta)), the formControluses to build its canonical subclass.- Parameters:
theta_or_num_controls – Rotation angle in radians, or the number of controls (always 1) in the
Controlform.num_controls_or_operation – Unused when called directly, or the
GateRYwhose angle is taken in theControlform.operation – Unused.
- class 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.
Matrix 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 – Rotation angle \(\lambda\) in radians, numeric or symbolic.
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.
Called directly as
GateCRZ(lmbda). The signature also acceptsGateCRZ(1, GateRZ(lmbda)), the formControluses to build its canonical subclass.- Parameters:
lmbda_or_num_controls – Rotation angle in radians, or the number of controls (always 1) in the
Controlform.num_controls_or_operation – Unused when called directly, or the
GateRZwhose angle is taken in theControlform.operation – Unused.