qrisp.QuantumVariable.reduce#

QuantumVariable.reduce(qubits, verify=False)[source]#

Reduces the qubit count of the QuantumVariable by removing a specified set of qubits.

Parameters
qubitslist

The qubits to remove from the QuantumVariable.

verifybool

Boolean value which indicates wether Qrisp should verify that the reduced qubits are in the \(\ket{0}\) state.

Raises
Exception

Qubits not present in QuantumVariable.

Exception

Verification that the given qubits are in \(\ket{0}\) state failed.

Examples

We create a QuantumVariable with 5 qubits and remove the first 2

>>> from qrisp import QuantumVariable
>>> qv = QuantumVariable(5)
>>> print(qv.reg)
[Qubit(qv.0), Qubit(qv.1), Qubit(qv.2), Qubit(qv.3), Qubit(qv.4)]
>>> qv.reduce(qv[:2])
>>> print(qv.reg)
[Qubit(qv.2), Qubit(qv.3), Qubit(qv.4)]