#VS2017 – Using MResetZ() to reset #Qubits in Q# and Microsoft Quantum Development Kit

Hi!

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.

I1

GitHub Source Code link

Happy QCoding!

Greetings @ Toronto

El Bruno

References

My Posts

 

Advertisements

4 thoughts on “#VS2017 – Using MResetZ() to reset #Qubits in Q# and Microsoft Quantum Development Kit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s