mimiqcircuits.operations.gates.generalized.rnz¶
RNZ (Multi-qubit Z-rotation) gate.
Classes
|
Multi-qubit Z-parity rotation. |
- class GateRNZ(*args)[source]¶
Bases:
GateMulti-qubit Z-parity rotation.
Applies \(e^{-i\frac{\theta}{2} Z^{\otimes n}}\): each computational basis state gets the phase \(e^{-i\theta/2}\) if it has an even number of ones and \(e^{i\theta/2}\) if odd.
Matrix Representation
\[\operatorname{RNZ}(\theta) = \operatorname{diag}\left( e^{-i(-1)^{|k|}\theta/2}\right)_{k=0}^{2^n-1}\]where \(|k|\) is the number of ones in the binary form of \(k\).
With fewer than two arguments the constructor returns a lazy expression that takes the missing arguments later.
- Parameters:
n (int) – Number of qubits, a positive integer.
theta – Rotation angle in radians, numeric or symbolic.
- Raises:
ValueError – If
nis not a positive integer or more than two arguments are given.
Examples
>>> from mimiqcircuits import * >>> from symengine import pi, Symbol >>> GateRNZ(2, pi/2) RNZ((1/2)*pi) >>> GateRNZ(2, Symbol('theta')).matrix() [exp(-1/2*I*theta), 0, 0, 0] [0, exp(1/2*I*theta), 0, 0] [0, 0, exp(1/2*I*theta), 0] [0, 0, 0, exp(-1/2*I*theta)] >>> c = Circuit() >>> c.push(GateRNZ(3, pi/2), 1, 2, 3) 4-qubit circuit with 1 instruction: └── RNZ((1/2)*pi) @ q[1:3] >>> GateRNZ(2, pi/2).power(2), GateRNZ(2, pi/2).inverse() (RNZ(pi), RNZ((-1/2)*pi)) >>> GateRNZ(2, pi/2).decompose() 2-qubit circuit with 3 instructions: ├── CX @ q[0], q[1] ├── RZ((1/2)*pi) @ q[1] └── CX @ q[0], q[1] >>> # lazy forms >>> GateRNZ() lazy GateRNZ(?, ?) >>> GateRNZ(2) lazy GateRNZ(2, ?)