ControlEnvironment#
- class ControlEnvironment(ctrl_qubits, ctrl_state=-1, ctrl_method=None, invert=False)[source]#
This class behaves similarly to ConditionEnvironment but instead of a function calculating a truth value, we supply a list of qubits. The environment’s content is then controlled on these qubits.
An alias for this QuantumEnvironment is “control”.
- Parameters:
- ctrl_qubitslist[Qubit]
A list of qubits on which to control the environment’s content.
- ctrl_stateint/str, optional
The computational basis state which is supposed to activate the environment. Can be supplied as a bitstring or integer. The default is “1111..”.
Examples
We create a QuantumVariable and control on some of it’s qubits using the control alias
from qrisp import QuantumVariable, QuantumString, multi_measurement, control, h qv = QuantumVariable(3) q_str = QuantumString() qv[:] = "011" h(qv[0]) with control(qv[:2], "11"): q_str += "hello world"
>>> print(multi_measurement([qv, q_str])) {('011', 'aaaaaaaaaaa'): 0.5, ('111', 'hello world'): 0.5}