qib.operator.gates.ControlledGate

class qib.operator.gates.ControlledGate(tgate: Gate, ncontrols: int, ctrl_state: Sequence[int] | None = None)[source]

Bases: Gate

A controlled quantum gate with an arbitrary number of control qubits. The control qubits have to be set explicitly. The target qubits (or particles) are specified via the target gate.

Methods

as_circuit_matrix

Generate the sparse matrix representation of the gate as element of a quantum circuit.

as_matrix

Generate the matrix representation of the controlled gate. Format: |control> x |target>.

as_qasm

Generate a Qobj OpenQASM representation of the gate.

as_tensornet

Generate a tensor network representation of the gate.

fields

Return the list of fields hosting the quantum particles which the gate acts on.

inverse

Return the inverse operator.

is_hermitian

Whether the gate is Hermitian.

is_unitary

A quantum gate is unitary by definition.

particles

Return the list of quantum particles the gate acts on.

set_control

Set the control qubits.

target_gate

Get the target gate.

Attributes

num_controls

The number of control qubits.

num_wires

The number of "wires" (or quantum particles) this gate acts on.

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

Generate the sparse matrix representation of the gate as element of a quantum circuit.

as_matrix()[source]

Generate the matrix representation of the controlled gate. Format: |control> x |target>

as_qasm()[source]

Generate a Qobj OpenQASM representation of the gate.

as_tensornet()[source]

Generate a tensor network representation of the gate.

fields()[source]

Return the list of fields hosting the quantum particles which the gate acts on.

inverse()[source]

Return the inverse operator.

is_hermitian()[source]

Whether the gate is Hermitian.

is_unitary()[source]

A quantum gate is unitary by definition.

property num_controls

The number of control qubits.

property num_wires

The number of “wires” (or quantum particles) this gate acts on.

particles()[source]

Return the list of quantum particles the gate acts on.

set_control(*args)[source]

Set the control qubits.

target_gate()[source]

Get the target gate.