qrisp.jasp.Jaspr.control#
- Jaspr.control(num_ctrl, ctrl_state=-1)[source]#
Returns the controlled version of the Jaspr. The control qubits are added to the signature of the Jaspr as the arguments after the QuantumCircuit.
- Parameters:
- num_ctrlint
The amount of controls to be added.
- ctrl_stateint of str, optional
The control state on which to activate. The default is -1.
- Returns:
- Jaspr
The controlled Jaspr.
Examples
We create a simple script and inspect the controlled version:
from qrisp import * from qrisp.jasp import make_jaspr def example_function(i): qv = QuantumVariable(i) cx(qv[0], qv[1]) t(qv[1]) return qv jaspr = make_jaspr(example_function)(2) print(jaspr.control(2)) # Yields # { lambda ; a:QuantumCircuit b:Qubit c:Qubit d:i32[]. let # e:QuantumCircuit f:QubitArray = create_qubits a 1 # g:Qubit = get_qubit f 0 # h:QuantumCircuit = ccx e b c g # i:QuantumCircuit j:QubitArray = create_qubits h d # k:Qubit = get_qubit j 0 # l:Qubit = get_qubit j 1 # m:QuantumCircuit = ccx i g k l # n:QuantumCircuit = ct m g l # o:QuantumCircuit = ccx n b c g # in (o, j) }
We see that the control qubits are part of the function signature (
a
andb
)