English
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

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 as data to the class constructor this provides no options on how the circuit is used to create an Operator. This constructor method lets you control how the Operator 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 input circuit has a layout set it will be ignored

  • layout (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 the circuit input. If specified the virtual bits in the Layout must be present in the circuit 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

Operator