MResetZ is a Q# operation that measures a qubit in the computational basis, resets it to |0⟩, and returns the measurement as a Result. section 4.1.3
Use MResetZ when reading qubits while restoring them to a known state:
- Call MResetZ for each qubit in an array. section 4.1.3
- Collect the returned Result values, which are Zero or One rather than ordinary numeric or Boolean values. section 4.1.3
- Print or otherwise process the results as classical information after measurement. section 4.1.3
Reading and validating a basis state
Allocate qubits, prepare a computational-basis state with X gates, read them using MResetZ, convert Zero and One results into an integer, and validate the value with Fact. section 4.1.3
Listing 4.3 Q# code to measure all qubits and return the results
operation ReadInformation(qs : Qubit[]) : Result[] {
mutable res = []; #1
for q in qs {
set res += [MResetZ(q)]; #2
}
return res;
}
Reference implementation for measuring every qubit and returning the collected Result array. section 4.1.3
