mimiqcircuits.operations.pairmeasure¶
Pair measurement operations (ZZ, XX, YY).
Classes
- class mimiqcircuits.operations.pairmeasure.MeasureZZ[source]¶
Bases:
AbstractMeasurementMeasureZZ operation.
The MeasureZZ operation measures the joint parity of two qubits in the Z-basis. This is achieved by applying a controlled-X (CX) gate, measuring the target qubit, and then applying another CX gate to undo the entanglement. The measurement result indicates whether the qubits are in the same or different states in the Z-basis.
See also
MeasureXX: Measure the joint parity of two qubits in the X-basis.MeasureYY: Measure the joint parity of two qubits in the Y-basis.Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(MeasureZZ(), 0, 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MZZ @ q[0:1], c[0] >>> c.decompose() 2-qubit, 1-bit circuit with 3 instructions: ├── CX @ q[0], q[1] ├── M @ q[1], c[0] └── CX @ q[0], q[1]
- class mimiqcircuits.operations.pairmeasure.MeasureXX[source]¶
Bases:
AbstractMeasurementMeasureXX operation.
The MeasureXX operation measures the joint parity of two qubits in the X-basis, that is the two-qubit Pauli operator \(X \otimes X\). Its decomposition applies a controlled-X (CX) gate from the first qubit to the second and a Hadamard (H) gate on the first qubit. Together they map \(X \otimes X\) to \(Z\) on the first qubit, which is then measured. The H and CX gates are applied again afterwards to undo the basis change, so the qubits are left in the post-measurement state of the \(X \otimes X\) measurement.
A result of 0 indicates that the qubits are in the same state, while a result of 1 indicates that they are in different states.
See also
MeasureZZ: Measure the joint parity of two qubits in the Z-basis.MeasureYY: Measure the joint parity of two qubits in the Y-basis.Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(MeasureXX(), 0, 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MXX @ q[0:1], c[0] >>> c.decompose() 2-qubit, 1-bit circuit with 5 instructions: ├── CX @ q[0], q[1] ├── U((1/2)*pi, 0, pi, 0.0) @ q[0] ├── M @ q[0], c[0] ├── U((1/2)*pi, 0, pi, 0.0) @ q[0] └── CX @ q[0], q[1]
- class mimiqcircuits.operations.pairmeasure.MeasureYY[source]¶
Bases:
AbstractMeasurementMeasureYY operation.
The MeasureYY operation measures the joint parity of two qubits in the Y-basis, that is the two-qubit Pauli operator \(Y \otimes Y\). Its decomposition applies an S gate to both qubits, a controlled-X (CX) gate from the first qubit to the second and a Hadamard (H) gate on the first qubit. Together they map \(Y \otimes Y\) to \(Z\) on the first qubit, which is then measured. The H and CX gates and an S† gate on both qubits are applied afterwards to undo the basis change, so the qubits are left in the post-measurement state of the \(Y \otimes Y\) measurement.
A result of 0 indicates that the qubits are in the same state, while a result of 1 indicates that they are in different states.
See also
MeasureZZ: Measure the joint parity of two qubits in the Z-basis.MeasureXX: Measure the joint parity of two qubits in the X-basis.Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(MeasureYY(), 0, 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MYY @ q[0:1], c[0] >>> c.decompose() 2-qubit, 1-bit circuit with 9 instructions: ├── U(0, 0, (1/2)*pi, 0.0) @ q[0] ├── U(0, 0, (1/2)*pi, 0.0) @ q[1] ├── CX @ q[0], q[1] ├── U((1/2)*pi, 0, pi, 0.0) @ q[0] ├── M @ q[0], c[0] ├── U((1/2)*pi, 0, pi, 0.0) @ q[0] ├── CX @ q[0], q[1] ├── U(0, 0, (-1/2)*pi, 0.0) @ q[0] └── U(0, 0, (-1/2)*pi, 0.0) @ q[1]