- perm_lock(qubits, message='')#
Locks a list of qubits such that only permeable gates can be executed on these qubits. This means that an error will be raised if the user attempts to perform any operation involving these qubits if the operation does not commute with the Z-operator of this qubit. For more information, what a permeable gate is, check the uncomputation documentation.
This can be helpfull as it forbids all operations that change that computational basis state of this qubit but still allow controling on this qubit or applying phase gates.
Using the keywoard message it is possible to extend the displayed error message.
The effect of this function can be reversed using perm_unlock.
- qubitslist[Qubit] or QuantumVariable
The qubits to phase-tolerantly lock.
- messagestr, optional
The message why these qubits are locked.
We create a QuantumChar, perm-lock it’s Qubits and attempt to initialize.
>>> from qrisp import QuantumChar, perm_lock, cx, p >>> q_ch_0 = QuantumChar() >>> perm_lock(q_ch_0) >>> q_ch_0[:] = "g" Exception: Tried to perform non-permeable operations on perm_locked qubits
We now create a second QuantumChar and perform a CNOT gate
>>> q_ch_1 = QuantumChar() >>> cx(q_ch_0, q_ch_1)
Phase-gates are possible, too
>>> p(0.1, q_ch_0)