qib.circuit.circuit.Circuit

class qib.circuit.circuit.Circuit(gates: Sequence[Gate | ControlInstruction] | None = None)[source]

Bases: object

A quantum circuit consists of a list of quantum gates and control instructions (e.g. measure, barrier, delay, etc.).

We follow the convention that the first gate in the list is applied first.

Methods

append_circuit

Append the gates from another quantum circuit to the current circuit.

append_gate

Append a quantum gate or a control instruction.

as_matrix

Generate the sparse matrix representation of the circuit.

as_qasm

Generate a list of Qobj OpenQASM instructions representation of the circuit.

as_tensornet

Generate a tensor network representation of the circuit.

clbits

Set of all classical bits appearing in the circuit.

fields

List of all fields appearing in the circuit.

inverse

Construct the "inverse" circuit: reversed list of adjoint gates.

particles

Set of all quantum particles appearing in the circuit.

prepend_circuit

Prepend the gates from another quantum circuit to the current circuit.

prepend_gate

Prepend a quantum gate or a control instruction.

append_circuit(other)[source]

Append the gates from another quantum circuit to the current circuit.

append_gate(gate: Gate | ControlInstruction)[source]

Append a quantum gate or a control instruction.

as_matrix(fields: Sequence[Field])[source]

Generate the sparse matrix representation of the circuit.

as_qasm()[source]

Generate a list of Qobj OpenQASM instructions representation of the circuit.

as_tensornet()[source]

Generate a tensor network representation of the circuit.

clbits()[source]

Set of all classical bits appearing in the circuit.

fields()[source]

List of all fields appearing in the circuit.

inverse()[source]

Construct the “inverse” circuit: reversed list of adjoint gates.

particles()[source]

Set of all quantum particles appearing in the circuit.

prepend_circuit(other)[source]

Prepend the gates from another quantum circuit to the current circuit.

prepend_gate(gate: Gate | ControlInstruction)[source]

Prepend a quantum gate or a control instruction.