autoqasm.simulator.linalg_utils module

autoqasm.simulator.linalg_utils.measurement_sample(prob: Iterable[float], target_count: int) tuple[int][source]

Draws a random measurement sample.

Parameters:
  • prob (Iterable[float]) – Probabilities of each measurement outcome. Possible measurement outcomes range from 0 to 2**target_count-1, meaning that len(prob) must be equal to 2**target_count.

  • target_count (int) – Number of bits in the resulting measurement.

Returns:

tuple[int] – Measurement outcomes 0 or 1 for each of the target_count bits.

autoqasm.simulator.linalg_utils.measurement_collapse_sv(state_vector: ndarray, targets: Iterable[int], outcome: ndarray) ndarray[source]

Collapses the state vector according to the given measurement outcome.

Parameters:
  • state_vector (np.ndarray) – The state vector prior to measurement.

  • targets (Iterable[int]) – The qubit indices that were measured.

  • outcome (np.ndarray) – Array of measurement outcomes 0 or 1.

Returns:

np.ndarray – The collapsed state vector after measurement.