Measure instruction
A measure instruction performs a measurement to its qubit argument and
assigns the outcome to a bit variable.
The measure instruction can either
- have no parameters
measure, which corresponds to a measurement in the Z-basis, or - accept 3 floating-point parameters
measure(0,0,1), which define the axis of the basis along which the measurement is to be performed.
Note
measure(0,0,1) is equal to the non-parameterized measure as \((0,0,1)\) defines the positive \(z\)-axis.
The general form of a measure instruction is as follows:
bit-argument = measure qubit-argument
bit-argument = measure(parameter-list) qubit-argument
Grammar for measure instruction
measure-instruction:
bit-argument = measure qubit-argument
bit-argument = measure parameters qubit-argument
bit-argument:
bit-variable
bit-index
bit-variable:
identifier
bit-index:
index
parameters:
( parameter-list )
parameter-list:
parameter
parameter-list , parameter
parameter:
floating-literal
qubit-argument:
qubit-variable
qubit-index
qubit-variable:
identifier
qubit-index:
index
Example
Note
The measure instruction accepts
SGMQ notation, similar to gates.
The following code snippet shows how the measure instruction might be used in context.
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.
To measure in the Hadamard basis (or X-basis) you can use the parameterized measure instruction to measure along the
\(x\)-axis, defined by \((1,0,0)\).
On the last line of the latter cQASM program the qubit is measured along the \(x\)-axis; the measurement outcome will (always) be 1, due to measuring the \(|1\rangle\) state in the X-basis.