After an intense week of events, this week it’s my turn to go back to the Quantum Computing studio. In this particular case, to a detail that we have to keep in mind when we work with Q #
When a qubit is in an eigenstate of the measurement operator, i.e., either in |0> or in |1>, we need to reset the Qubit before the end of an operation. Qubits need to be in |0> when they are released, so we have to manually reset the qubit before releasing it using the Z() operation if needed.
Well, let’s take as a basis one in which we initialize a Qubit and apply an operation Hadamard operation as shown in the following code
In line 10 I store the state of the Qubit in the return variable and then on lines 11 to 14 verify that the state of the same is Zero. If not, I need to reset the Qubit to Zero before the end of the operation on line 13.
Well, this code works, and that’s amazing! However when we use the Microsoft Quantum DevKit we also have an operation that allows us to obtain the status of a Qubit and release it in a single operation. This operation is MResetZ(). The same previous code using this operation it is much more nice to read
As we can see, the main change is in line 10 where I assign the state of the Qubit to the return variable and also reset the Qubit to Zero.
Finally, from a Console App I invoke both operations and the result is equal.
GitHub Source Code link
Greetings @ Toronto
- Microsoft Quantum Development Kit
- Q# Reference, M operation
- Q# Reference, H operation
- Q# Reference, MResetZ operation
- El Bruno, Qubit operations in Q#
- El Bruno, Information about Simulators on Microsoft Quantum Development Kit (Do you have 16 TB RAM?)
- El Bruno, Hello QWorld using Microsoft #Quantum Development Kit (fix to build the project) [Updated]
- El Bruno, More information about the Microsoft bet in Quantum Computing
- El Bruno, Quantum Computing, let’s add this one to Artificial Intelligence and Mixed Reality!