Built-in quantum instructions¶
This section describes built-in non-unitary operations.
Initialization¶
The statement reset qubit|qubit[];
resets a qubit or quantum register to the state
\(|0\rangle\). This corresponds to a partial trace over those qubits
(i.e. discarding them) before replacing them with
\(|0\rangle\langle 0|\). Reset is shown in Fig. 2.
// Initialize and reset a register of 10 qubits
qubit[10] qubits;
reset qubits;
Fig. 2 The reset
statement prepares a qubit or quantum register in the state \(|0\rangle\).¶
Measurement¶
The statement bit|bit[] = measure qubit|qreg;
measures the qubit(s) in the \(Z\)-basis and assigns
the measurement outcome(s) to the target bit(s). For backwards
compatibility this is equivalent to measure qubit|qubit[] -> bit|bit[];
which is also supported. Measurement
corresponds to a projection onto one of the eigenstates of \(Z\),
and qubit(s) are immediately available for further quantum computation.
Both arguments must be register-type, or both must be bit-type. If both
arguments are register-type and have the same size, the statement b = measure a;
broadcasts to b[j] = measure a[j];
for each index j
into register a
. Measurement is shown in
Fig. 3.
// Initialize, flip and measure a register of 10 qubits
qubit[10] qubits;
bit[10] bits;
x qubits;
bits = measure qubits;
Fig. 3 The measure
statement projectively measures a qubit or each qubit of a quantum
register. The measurement projects onto the \(Z\)-basis and leaves qubits available for further
operations. The top row of circuits depicts single-qubit measurement using the statement
c[0] = measure q[0];
while the bottom depicts measurement of an entire register using the
statement c = measure q;
. The center circuit of the top row depicts measurement as the
final operation on q[0]
.¶