loqs.tools.qsimtools¶
A collection of tools useful for QSimQuantumState objects.
Primarily verbose printing for debugging currently.
Functions¶
get_state_probs_phases ¶
get_state_probs_phases(qsim_state: QSimQuantumState)
Compute computational basis probabilities and phases.
This leaves the input state unchanged, but returns the probabilities
of measuring each computational basis state and phase relative to
the smallest bitstring with nonzero probability (the all 0 string
when it has amplitude). If a basis state is missing, it is assumed to
have no probability of being observed; phases has exactly the
bitstrings with nonzero probability.
Phases are found by a walk over single bit flips between nonzero
bitstrings, with a Hadamard test on each flipped qubit. A ValueError
is raised, rather than a wrong sign returned, when the support isn't
linked by single flips (e.g. a GHZ state) or a phase is complex. It
may also be raised, though this isn't guaranteed, for a mixed state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qsim_state
|
QSimQuantumState
|
State backend object to analyze |
required |
Returns:
| Name | Type | Description |
|---|---|---|
qubits |
List of qubit labels |
|
probs |
A dictionary of bitstring keys and probability values |
|
phases |
A dictionary of bitstring keys and phase (relative to the smallest nonzero bitstring) values |
print_state_probs_phases ¶
print_state_probs_phases(qsim_state: QSimQuantumState)
Pretty-print the output of get_state_probs_phases().
Refer to get_state_probs_phases() for documentation.