PartialVector

class guppylang.emulator.PartialVector(base_state: ndarray[tuple[Any, ...], dtype[complexfloating]], total_qubits: int, specified_qubits: list[int])[source]

Partial state vector for simulator backends with statevector representation. Partial in the sense that some qubits may be traced out, and the state is represented as a distribution of state vectors.

__abstractmethods__ = frozenset({})
__init__(base_state: ndarray[tuple[Any, ...], dtype[complexfloating]], total_qubits: int, specified_qubits: list[int]) None[source]

Initialize a PartialVector from a base state vector, total qubits, and specified qubits.

Args:

base_state: The state vector over all qubits in the system. total_qubits: Total number of qubits in the system specified_qubits: List of specified qubits in the state. Those not in this list are considered traced out.

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

property specified_qubits: list[int]

List of specified qubits in the state. Those not in this list are considered traced out.

state_distribution(zero_threshold: float = 1e-12) list[TracedState[ndarray[tuple[Any, ...], dtype[complexfloating]]]][source]

Distribution of states after tracing out unspecified qubits. In general this results in a distribution of states, each with a probability.

Args:
zero_threshold: Threshold for considering a state amplitude to be zero.

Defaults to 1e-12.

Returns:

List of traced states, each with a state vector and a probability.

property total_qubits: int

Total number of qubits in the state.