mimiqcircuits.operations.measure¶
Measurement operations.
Classes
|
|
|
Measure operation. |
|
Single qubit measurement operation in the X-basis. |
|
Single qubit measurement operation in the Y-basis. |
|
Single qubit measurement operation in the Z-basis. |
- class mimiqcircuits.operations.measure.Measure[source]¶
Bases:
AbstractMeasurementMeasure operation.
This operation performs a measurement in the computational basis (Z-basis) and stores the result in a classical register.
The measurement projects the quantum state onto either the \(|0⟩\) or \(|1⟩\) state, corresponding to the classical bit values of 0 and 1, respectively.
Warning
Measure is non-reversible.
Examples
Adding Measure operation to the Circuit (The qubits (first arg) and the bits (second arg) can be: range, list, tuple, set or int)
>>> from mimiqcircuits import * >>> c= Circuit() >>> c.push(Measure(),0,0) 1-qubit, 1-bit circuit with 1 instruction: └── M @ q[0], c[0]
>>> from mimiqcircuits import * >>> c= Circuit() >>> c.push(Measure(), range(0,3), range(0,3)) 3-qubit, 3-bit circuit with 3 instructions: ├── M @ q[0], c[0] ├── M @ q[1], c[1] └── M @ q[2], c[2]
- class mimiqcircuits.operations.measure.MeasureX[source]¶
Bases:
AbstractMeasurementSingle qubit measurement operation in the X-basis.
This operation projects the quantum state onto the X-basis and stores the result of such measurement in a classical register. The measurement is performed by first applying a Hadamard gate to rotate the qubit’s state into the computational basis, performing a standard Z-basis measurement, and then applying another Hadamard gate to return the qubit to its original basis.
Warning
MeasureX is non-reversible.
Examples
>>> from mimiqcircuits import * >>> MeasureX() MX
>>> c = Circuit() >>> c.push(MeasureX(), 2, 1) 3-qubit, 2-bit circuit with 1 instruction: └── MX @ q[2], c[1]
>>> c.push(MeasureX(), 3, 4) 4-qubit, 5-bit circuit with 2 instructions: ├── MX @ q[2], c[1] └── MX @ q[3], c[4]
- class mimiqcircuits.operations.measure.MeasureY[source]¶
Bases:
AbstractMeasurementSingle qubit measurement operation in the Y-basis.
This operation projects the quantum state onto the Y-basis and stores the result of such measurement in a classical register. The measurement is performed by first applying a \(R_y(\pi/2)\) rotation gate to rotate the qubit’s state into the computational basis, performing a standard Z-basis measurement, and then applying another \(R_y(-\pi/2)\) rotation to return the qubit to its original basis.
Warning
MeasureY is non-reversible.
Examples
>>> from mimiqcircuits import * >>> MeasureY() MY
>>> c = Circuit() >>> c.push(MeasureY(), 2, 1) 3-qubit, 2-bit circuit with 1 instruction: └── MY @ q[2], c[1]
>>> c.push(MeasureY(), 3, 4) 4-qubit, 5-bit circuit with 2 instructions: ├── MY @ q[2], c[1] └── MY @ q[3], c[4]
- class mimiqcircuits.operations.measure.MeasureZ[source]¶
Bases:
AbstractMeasurementSingle qubit measurement operation in the Z-basis.
This class returns an instance of the
Measureoperation, effectively acting as an alias for Z-basis measurement.Warning
MeasureZ is non-reversible.
Examples
>>> from mimiqcircuits import * >>> MeasureZ() M
>>> c = Circuit() >>> c.push(MeasureZ(), 0, 0) 1-qubit, 1-bit circuit with 1 instruction: └── M @ q[0], c[0]
>>> c.push(MeasureZ(), 1, 2) 2-qubit, 3-bit circuit with 2 instructions: ├── M @ q[0], c[0] └── M @ q[1], c[2]