QulacsCircuit

class QulacsCircuit

Qulacs-based quantum circuit implementation.

Wraps QuantumCircuit and Observable from Qulacs to satisfy the circuit protocol interface required by QAOA circuit construction.

Methods

__init__

add_cnot_gate

Apply a CNOT gate with control qubit i and target qubit j.

add_cz_gate

Apply a controlled-Z gate between qubit i and qubit j.

add_h_gate

Apply a Hadamard gate to qubit i.

add_observable_rotation_gate

Apply a Hamiltonian evolution gate exp(-i * value * H).

add_p_gate

Apply a phase gate to qubit i.

add_rx_gate

Apply an Rx rotation gate to qubit i.

add_ry_gate

Apply an Ry rotation gate to qubit i.

add_rz_gate

Apply an Rz rotation gate to qubit i.

add_s_gate

Apply an S gate to qubit i, inducing a pi/2 phase on the |1> state.

add_sdg_gate

Apply the adjoint of the S gate to qubit i, inducing a -pi/2 phase on the |1> state.

add_swap_gate

Apply a SWAP gate between qubit i and qubit j.

add_sx_gate

Apply a sqrt(X) gate to qubit i.

add_sxdg_gate

Apply the adjoint of the sqrt(X) gate to qubit i.

add_t_gate

Apply a T gate to qubit i, inducing a pi/4 phase on the |1> state.

add_tdg_gate

Apply the adjoint of the T gate to qubit i, inducing a -pi/4 phase on the |1> state.

add_u_gate

Apply a general single-qubit unitary gate to qubit i.

add_x_gate

Apply a Pauli-X gate to qubit i.

add_y_gate

Apply a Pauli-Y gate to qubit i.

add_z_gate

Apply a Pauli-Z gate to qubit i.

get_observable_class

Return the observable implementation class used by this circuit.

Attributes

num_qubits

Number of qubits in the circuit.

raw

Underlying Qulacs QuantumCircuit object.

class QulacsObservable

Observable builder backed by Observable from Qulacs.

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: Observable | None = 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).

パラメータ:
  • num_qubits (int) -- Total number of qubits in the operator (unused for Qulacs).

  • bit_index (int | Iterable[int]) -- Qubit index or indices for the X operator.

  • value (float) -- Coefficient of the term.

戻り値:

This instance, for chaining.

戻り値の型:

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).

パラメータ:
  • num_qubits (int) -- Total number of qubits in the operator (unused for Qulacs).

  • bit_index (int | Iterable[int]) -- Qubit index or indices for the Y operator.

  • value (float) -- Coefficient of the term.

戻り値:

This instance, for chaining.

戻り値の型:

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).

パラメータ:
  • num_qubits (int) -- Total number of qubits in the operator (unused for Qulacs).

  • bit_index (int | Iterable[int]) -- Qubit index or indices for the Z operator.

  • value (float) -- Coefficient of the term.

戻り値:

This instance, for chaining.

戻り値の型:

Self

property raw: Observable

Return the underlying Qulacs Observable.

T_circuit

QuantumCircuit の別名です。

T_obs

Observable の別名です。

classmethod get_observable_class() type[QulacsObservable]

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.

パラメータ:
  • i (int) -- Control qubit index.

  • j (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_cz_gate(i: int, j: int) Self

Apply a controlled-Z gate between qubit i and qubit j.

パラメータ:
  • i (int) -- Control qubit index.

  • j (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_h_gate(i: int) Self

Apply a Hadamard gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_observable_rotation_gate(
op_f: T_obs | ObservableProtocol[T_obs],
value: float,
num_qubits: int,
) Self

Apply a Hamiltonian evolution gate exp(-i * value * H).

パラメータ:
  • op_f (ObservableProtocol[T_obs]) -- Observable whose raw Observable is used as the Hamiltonian H.

  • value (float) -- Evolution time (rotation angle).

  • num_qubits (int) -- Number of qubits the gate acts on (unused for Qulacs).

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_p_gate(i: int, value: float) Self

Apply a phase gate to qubit i.

パラメータ:
  • i (int) -- Target qubit index.

  • value (float) -- Phase angle in radians.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_rx_gate(i: int, value: float) Self

Apply an Rx rotation gate to qubit i.

パラメータ:
  • i (int) -- Target qubit index.

  • value (float) -- Rotation angle in radians.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_ry_gate(i: int, value: float) Self

Apply an Ry rotation gate to qubit i.

パラメータ:
  • i (int) -- Target qubit index.

  • value (float) -- Rotation angle in radians.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_rz_gate(i: int, value: float) Self

Apply an Rz rotation gate to qubit i.

パラメータ:
  • i (int) -- Target qubit index.

  • value (float) -- Rotation angle in radians.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_s_gate(i: int) Self

Apply an S gate to qubit i, inducing a pi/2 phase on the |1> state.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

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.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_swap_gate(i: int, j: int) Self

Apply a SWAP gate between qubit i and qubit j.

パラメータ:
  • i (int) -- First qubit index.

  • j (int) -- Second qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_sx_gate(i: int) Self

Apply a sqrt(X) gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_sxdg_gate(i: int) Self

Apply the adjoint of the sqrt(X) gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_t_gate(i: int) Self

Apply a T gate to qubit i, inducing a pi/4 phase on the |1> state.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

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.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_u_gate(i: int, theta: float, phi: float, lam: float) Self

Apply a general single-qubit unitary gate to qubit i.

パラメータ:
  • 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.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_x_gate(i: int) Self

Apply a Pauli-X gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_y_gate(i: int) Self

Apply a Pauli-Y gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

add_z_gate(i: int) Self

Apply a Pauli-Z gate to qubit i.

パラメータ:

i (int) -- Target qubit index.

戻り値:

This instance, for chaining.

戻り値の型:

Self

property num_qubits: int

Number of qubits in the circuit.

property raw: QuantumCircuit

Underlying Qulacs QuantumCircuit object.