Init instruction
In general, qubits are initialized in the \(|0\rangle\) state.
Nonetheless, to explicitly initialize (particular) qubits in the \(|0\rangle\) state
one can use the init instruction.
The general form of an init instruction is as follows:
init qubit-argument
Grammar for init instruction
init-instruction:
init qubit-argument
qubit-argument:
qubit-variable
qubit-index
qubit-variable:
identifier
qubit-index:
index
Note
The init instruction accepts
SGMQ notation, similar to gates.
The following code snippet shows how the init instruction might be used in context.
In the code example above, the qubits are first declared and subsequently initialized.
Note that the initialization of qubits needs to be done before any instruction
(excluding a control instruction)
is applied to them (see warning below).
If one wishes to reset the state of the qubit to \(|0\rangle\) mid-circuit,
one should use the reset instruction.
Warning
Initialization of a qubit can only be done immediately after declaration of the qubit, i.e., it is not possible to initialize a qubit, if prior to that an instruction was applied to the qubit (excluding a control instruction).