QiskitCircuit¶
- class QiskitCircuit¶
Qiskit-based quantum circuit implementation.
Wraps
QuantumCircuitandSparsePauliOpto satisfy the circuit protocol interface required by QAOA circuit construction.Methods
Apply a CNOT gate with control qubit i and target qubit j.
Apply a controlled-Z gate between qubit i and qubit j.
Apply a Hadamard gate to qubit i.
Apply a Hamiltonian evolution gate
exp(-i * value * H).Apply a phase gate to qubit i.
Apply an Rx rotation gate to qubit i.
Apply an Ry rotation gate to qubit i.
Apply an Rz rotation gate to qubit i.
Apply an S gate to qubit i, inducing a pi/2 phase on the |1> state.
Apply the adjoint of the S gate to qubit i, inducing a -pi/2 phase on the |1> state.
Apply a SWAP gate between qubit i and qubit j.
Apply a sqrt(X) gate to qubit i.
Apply the adjoint of the sqrt(X) gate to qubit i.
Apply a T gate to qubit i, inducing a pi/4 phase on the |1> state.
Apply the adjoint of the T gate to qubit i, inducing a -pi/4 phase on the |1> state.
Apply a general single-qubit unitary gate to qubit i.
Apply a Pauli-X gate to qubit i.
Apply a Pauli-Y gate to qubit i.
Apply a Pauli-Z gate to qubit i.
Return the observable implementation class used by this circuit.
Attributes
Number of qubits in the circuit.
Underlying
QuantumCircuitobject.- class QiskitObservable¶
Observable builder backed by
SparsePauliOp.Accumulates Pauli-X and Pauli-Z terms to construct a Hamiltonian used as the generator of a unitary rotation gate.
- __init__(
- num_qubits: int,
- _obs: SparsePauliOp | None = None,
- add_pauli_x(num_qubits: int, bit_index: int, value: float) Self¶
- add_pauli_x(num_qubits: int, bit_index: Iterable[int], value: float) Self
Add a weighted Pauli-X term acting on the specified qubit(s).
- Parameters:
num_qubits (int) – Total number of qubits in the operator.
bit_index (int | Iterable[int]) – Qubit index or indices for the X operator.
value (float) – Coefficient of the term.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_pauli_y(num_qubits: int, bit_index: int, value: float) Self¶
- add_pauli_y(num_qubits: int, bit_index: Iterable[int], value: float) Self
Add a weighted Pauli-Y term acting on the specified qubit(s).
- Parameters:
num_qubits (int) – Total number of qubits in the operator.
bit_index (int | Iterable[int]) – Qubit index or indices for the Y operator.
value (float) – Coefficient of the term.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_pauli_z(num_qubits: int, bit_index: int, value: float) Self¶
- add_pauli_z(num_qubits: int, bit_index: Iterable[int], value: float) Self
Add a weighted Pauli-Z term acting on the specified qubit(s).
- Parameters:
num_qubits (int) – Total number of qubits in the operator.
bit_index (int | Iterable[int]) – Qubit index or indices for the Z operator.
value (float) – Coefficient of the term.
- Returns:
This instance, for chaining.
- Return type:
Self
- property raw: SparsePauliOp¶
Return the underlying
SparsePauliOp.
- T_circuit¶
alias of
QuantumCircuit
- T_obs¶
alias of
SparsePauliOp
- classmethod get_observable_class() type[QiskitObservable]¶
Return the observable implementation class used by this circuit.
- __init__(num_qubits: int) None¶
- add_cnot_gate(i: int, j: int) Self¶
Apply a CNOT gate with control qubit i and target qubit j.
- Parameters:
i (int) – Control qubit index.
j (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_cz_gate(i: int, j: int) Self¶
Apply a controlled-Z gate between qubit i and qubit j.
- Parameters:
i (int) – Control qubit index.
j (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_h_gate(i: int) Self¶
Apply a Hadamard gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_observable_rotation_gate( ) Self¶
Apply a Hamiltonian evolution gate
exp(-i * value * H).Appends a
PauliEvolutionGategenerated from op_f to the circuit.- Parameters:
op_f (ObservableProtocol[T_obs]) – Observable whose raw
SparsePauliOpis used as the Hamiltonian H.value (float) – Evolution time (rotation angle).
num_qubits (int) – Number of qubits the gate acts on.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_p_gate(i: int, value: float) Self¶
Apply a phase gate to qubit i.
- Parameters:
i (int) – Target qubit index.
value (float) – Phase angle in radians.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_rx_gate(i: int, value: float) Self¶
Apply an Rx rotation gate to qubit i.
- Parameters:
i (int) – Target qubit index.
value (float) – Rotation angle in radians.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_ry_gate(i: int, value: float) Self¶
Apply an Ry rotation gate to qubit i.
- Parameters:
i (int) – Target qubit index.
value (float) – Rotation angle in radians.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_rz_gate(i: int, value: float) Self¶
Apply an Rz rotation gate to qubit i.
- Parameters:
i (int) – Target qubit index.
value (float) – Rotation angle in radians.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_s_gate(i: int) Self¶
Apply an S gate to qubit i, inducing a pi/2 phase on the |1> state.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_sdg_gate(i: int) Self¶
Apply the adjoint of the S gate to qubit i, inducing a -pi/2 phase on the |1> state.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_swap_gate(i: int, j: int) Self¶
Apply a SWAP gate between qubit i and qubit j.
- Parameters:
i (int) – First qubit index.
j (int) – Second qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_sx_gate(i: int) Self¶
Apply a sqrt(X) gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_sxdg_gate(i: int) Self¶
Apply the adjoint of the sqrt(X) gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_t_gate(i: int) Self¶
Apply a T gate to qubit i, inducing a pi/4 phase on the |1> state.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_tdg_gate(i: int) Self¶
Apply the adjoint of the T gate to qubit i, inducing a -pi/4 phase on the |1> state.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_u_gate(i: int, theta: float, phi: float, lam: float) Self¶
Apply a general single-qubit unitary gate to qubit i.
- Parameters:
i (int) – Target qubit index.
theta (float) – First Euler angle in radians.
phi (float) – Second Euler angle in radians.
lam (float) – Third Euler angle in radians.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_x_gate(i: int) Self¶
Apply a Pauli-X gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_y_gate(i: int) Self¶
Apply a Pauli-Y gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- add_z_gate(i: int) Self¶
Apply a Pauli-Z gate to qubit i.
- Parameters:
i (int) – Target qubit index.
- Returns:
This instance, for chaining.
- Return type:
Self
- property num_qubits: int¶
Number of qubits in the circuit.
- property raw: QuantumCircuit¶
Underlying
QuantumCircuitobject.