Skip to content

Latest commit

 

History

History
 
 

measurement

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type languages products description urlFragment
sample
qsharp
qdk
This sample demonstrates the use of measurement operations to measure one or more qubits.
measuring-qubits

Measuring Qubits

This sample demonstrates:

  • The use of measurement operations to measure one or more qubits, getting classical data back that can be used in classical logic.
  • How to use assertions to build tests for expected behaviour of operations that involve measurements.
  • Resetting previously allocated qubits.

In Q#, the most basic measurement operation is the M operation, which measures a single qubit in the computational basis (sometimes also called the 𝑍-basis). In this sample, we show how M can be used to sample random numbers, and to measure registers of qubits.

Prerequisites

Running the Sample

To run the sample, use the dotnet run command from your terminal.

Manifest

Further resources