mimiqcircuits.operations.gates.standard.cphase¶
Controlled-Phase gate.
Classes
|
Two qubit Controlled-Phase gate. |
- class mimiqcircuits.operations.gates.standard.cphase.GateCP(num_controls=None, operation=None, *args, **kwargs)[source]¶
Bases:
ControlTwo qubit Controlled-Phase gate.
By convention, the first qubit is the control and the second is the target
See Also
GatePMatrix 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 in radians.
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).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]
- __init__(lmbda_or_num_controls, num_controls_or_operation=None, operation=None)[source]¶
Initialize a CP gate.
- Parameters:
lmbda_or_num_controls – Phase 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 GateP operation when called from Control’s canonical creation.
operation – Ignored (for compatibility).