qrisp.jasp.Jaspr.to_qc#
- Jaspr.to_qc(*args)[source]#
Converts the Jaspr into a QuantumCircuit if applicable. Circuit conversion of algorithms involving realtime computations is not possible.
Any computations that perform classical postprocessing of measurements can not be reflected within the QuantumCircuit object itself and will generate an object of type
ProcessedMeasurement. These objects hold no further information and are simply used as placeholders to emulate the computation.- Parameters:
- *argstuple
The arguments to call the Jaspr with.
- Returns:
- return_valuestuple
The return values of the Jaspr. QuantumVariable return types are returned as lists of Qubits.
- QuantumCircuit
The resulting QuantumCircuit.
Examples
We create a simple script and inspect the QuantumCircuit:
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) qb_list, qc = jaspr.to_qc(2) print(qc) # Yields # qb_0: ──■─────── # ┌─┴─┐┌───┐ # qb_1: ┤ X ├┤ T ├ # └───┘└───┘
To demonstrate the behavior under measurement post-processing, we build a similar script:
from qrisp import ProcessedMeasurement def example_function(i): qf = QuantumFloat(i) cx(qf[0], qf[1]) t(qf[1]) meas_res = measure(qf) # Perform classical post processing meas_res *= 2 return meas_res jaspr = make_jaspr(example_function)(2) meas_res, qc = jaspr.to_qc(2) print(isinstance(meas_res, ProcessedMeasurement)) # True