qiskit.quantum_info.Operator.from_circuit¶
- classmethod Operator.from_circuit(circuit, ignore_set_layout=False, layout=None, final_layout=None)[source]¶
Create a new Operator object from a
QuantumCircuit
While a
QuantumCircuit
object can passed directly asdata
to the class constructor this provides no options on how the circuit is used to create anOperator
. This constructor method lets you control how theOperator
is created so it can be adjusted for a particular use case.By default this constructor method will permute the qubits based on a configured initial layout (i.e. after it was transpiled). It also provides an option to manually provide a
Layout
object directly.- Parameters
circuit (QuantumCircuit) – The
QuantumCircuit
to create an Operator object from.ignore_set_layout (bool) – When set to
True
if the inputcircuit
has a layout set it will be ignoredlayout (Layout) – If specified this kwarg can be used to specify a particular layout to use to permute the qubits in the created
Operator
. If this is specified it will be used instead of a layout contained in thecircuit
input. If specified the virtual bits in theLayout
must be present in thecircuit
input.final_layout (Layout) – If specified this kwarg can be used to represent the output permutation caused by swap insertions during the routing stage of the transpiler.
- Returns
An operator representing the input circuit
- Return type