mimiqcircuits.operations.measurereset¶
Measure and reset operations.
Classes
Measure a qubit in the Z basis, then reset it to \(|0⟩\). |
|
Measure a qubit in the X basis, then reset it to \(|+⟩\). |
|
Measure a qubit in the Y basis, then reset it to \(|{+i}⟩\). |
|
Alias of |
- class MeasureReset[source]¶
Bases:
AbstractMeasurementMeasure a qubit in the Z basis, then reset it to \(|0⟩\).
Writes the outcome to a classical bit and then applies
GateXto the qubit if the outcome is 1, which leaves it in \(|0⟩\). It decomposes intoMeasurefollowed by anIfStatementofGateXconditioned on that bit. The instruction takes one qubit and one bit.Warning
Not reversible:
inverse,powerandcontrolraiseTypeError.See also
MeasureResetX,MeasureResetY,ResetExamples
>>> from mimiqcircuits import * >>> # measure qubit 1 into bit 0 and leave it in |0> >>> c = Circuit() >>> c.push(MeasureReset(), 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MR @ q[1], c[0] >>> # the same as a measurement followed by a conditional X >>> MeasureReset().decompose() 1-qubit, 1-bit circuit with 2 instructions: ├── M @ q[0], c[0] └── IF(c==1) X @ q[0], condition[0]
- class MeasureResetX[source]¶
Bases:
AbstractMeasurementMeasure a qubit in the X basis, then reset it to \(|+⟩\).
Writes 0 for \(|+⟩\) and 1 for \(|-⟩\) to a classical bit and leaves the qubit in \(|+⟩\). It decomposes into a Hadamard gate, a
MeasureResetand a second Hadamard gate. The instruction takes one qubit and one bit.Warning
Not reversible:
inverse,powerandcontrolraiseTypeError.See also
Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(MeasureResetX(), 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MRX @ q[1], c[0] >>> # rotate to the Z basis, measure and reset, rotate back >>> MeasureResetX().decompose() 1-qubit, 1-bit circuit with 3 instructions: ├── H @ q[0] ├── MR @ q[0], c[0] └── H @ q[0]
- class MeasureResetY[source]¶
Bases:
AbstractMeasurementMeasure a qubit in the Y basis, then reset it to \(|{+i}⟩\).
Writes 0 for \(|{+i}⟩\) and 1 for \(|{-i}⟩\) to a classical bit and leaves the qubit in \(|{+i}⟩\). It decomposes into a
GateHYZ, aMeasureResetand a secondGateHYZ. The instruction takes one qubit and one bit.Warning
Not reversible:
inverse,powerandcontrolraiseTypeError.See also
Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(MeasureResetY(), 1, 0) 2-qubit, 1-bit circuit with 1 instruction: └── MRY @ q[1], c[0] >>> # rotate to the Z basis, measure and reset, rotate back >>> MeasureResetY().decompose() 1-qubit, 1-bit circuit with 3 instructions: ├── HYZ @ q[0] ├── MR @ q[0], c[0] └── HYZ @ q[0]
- class MeasureResetZ[source]¶
Bases:
AbstractMeasurementAlias of
MeasureReset.MeasureResetZ()returns aMeasureResetinstance.Examples
>>> from mimiqcircuits import * >>> MeasureResetZ() MR