Measure instruction

A measure instruction performs a measurement to its qubit argument and assigns the outcome to a bit variable. The general form of a measure instruction is as follows:

bit-argument = measure qubit-argument

Grammar for measure instruction

measure-instruction:
bit-argument = measure qubit-argument

bit-argument:
bit-variable
bit-index

bit-variable:
identifier

bit-index:
index

qubit-argument:
qubit-variable
qubit-index

qubit-variable:
identifier

qubit-index:
index

Example

1
2
3
qubit q
bit b
b = measure q
1
2
3
qubit[5] q
bit[2] b
b[0, 1] = measure q[2, 4]

Note

The measure instruction accepts SGMQ notation, similar to gates.

The following code snippet shows how the measure instruction might be used in context.

1
2
3
4
5
6
7
8
9
version 3.0

qubit[2] q
bit[2] b

H q[0]
CNOT q[0], q[1]

b = measure q  // Measurement in the standard basis.

On the last line of this simple cQASM program, the respective states of both qubits in the qubit register are measured along the standard/computational basis.