spheres.utils¶
Miscellaneous useful functions.
Functions
|
Binomial coefficient \(\binom{n}{k} = \frac{n!}{k!(n-k)!}\) |
|
Generates a basis vector corresponding to a given bitstring, which may be a list of integers or a string of integers. |
|
Compares two vectors disregarding their overall complex phase. |
|
Compares two lists of spinors, disregarding both their phases, as well as their ordering in the list. |
|
Compares two sets of vectors regardless of their ordering up to some precision. |
|
Extracts components of qt.Qobj, whether bra or ket, as a numpy array. |
|
Converts a density matrix to a pure vector if it’s rank-1. |
|
Prints a pretty representation of a state in Dirac braket notation. |
|
Try to adjust the ordering of a list of stars to keep continuity, so that they are in the “same order.” Not always reliable. |
|
Flattens list of lists. |
|
Given a dictionary mapping Pauli strings to components, returns the corresponding density matrix/operator. |
|
Given a state and a set of projectors, calculates the probability of each outcome, and returns an outcome index with that probability. |
|
Normalizes numpy vector. |
Normalizes the phase of a complex vector (np.ndarray or qt.Qobj). |
|
|
Generates the Pauli basis for n qubits. |
|
Extracts phase of a complex vector (np.ndarray or qt.Qobj) by finding the first non-zero component and returning its phase. |
|
Extracts phase angle of a complex vector (np.ndarray or qt.Qobj) by finding the first non-zero component and returning its phase angle. |
|
Computes area of spherical polygon. |
|
Returns XYZ expectation values for each qubit in a tensor product. |
|
Generates (n) random extended complex coordinate(s) whose real and imaginary parts are normally distributed, and ten percent of the time, we return \(\infty\). |
|
Generates (n) random point(s) on the unit sphere in spherical coordinates. |
|
Generates (n) random point(s) on the unit sphere in cartesian coordinates. |
|
Returns XYZ expectation values for a spin-j state. |
|
Upgrades an operator to act on the i’th subspace of n subsystems. |
|
Expands a state/operator in the Pauli basis. |