Simulators#

Simulators for running circuits locally.

Contains a state-vector simulator able to return the resulting state vector after running a circuit on an all-zero initialized basis state. Supports both the little- and big-endian conventions.

Operation-Generation Module#

Simulator Module#

sample_qubit(qubit: int, state: ndarray[Any, dtype[_ScalarType_co]], rng: Generator, collapse_state: bool = True, little_endian: bool = False) int#

Sample a single qubit.

Parameters:
  • qubit – The qubit index that is measured.

  • state – The state to sample from.

  • rng – Random number generator to use for measuring in the computational basis.

  • collapse_state – Whether to collapse the state after measuring.

  • little_endian – If true, return the state vector using little-endian indexing for the qubits. Otherwise use big-endian.

Returns:

The measurement sample (0 or 1).

Return type:

int

simulate(circuit: Circuit, mixed_state: bool = False, little_endian: bool = False, rng_seed: int | None = None) None#

Simulate the given circuit with either a state vector or density matrix simulation.

The resulting state is stored in the circuit object, together with the measured value in the classical register.

Parameters:
  • circuit – The circuit to simulate.

  • mixed_state – If true, use the full density matrix method to simulate the circuit. Otherwise, simulate using the state vector method.

  • little_endian – If true, return the state vector using little-endian indexing for the qubits. Otherwise use big-endian.