qutree package#
Plot sets of multiqubit quantum pure states as a binary tree of Bloch spheres.
- class qutree.BBT(num_qubits)[source]#
Bases:
objectClass containing the data to plot the Bloch Binary Tree.
- Parameters:
num_qubits (int) – number of qubits
- add_data(states, colors=None, cmap='jet')[source]#
Add data of states to the tree computing the Bloch spheres parameters.
- Parameters:
states (ndarray) – complex array of M samples
colors (Optional[ndarray]) – complex array of either Mx4 for already generated colors, M for values between 0 and 1 that will follow the colormap, by default it will be the indexes.
cmap (str) – string name of a matplotlib colormap (default : ‘jet’)
- Return type:
None
- plot_tree(azim=-40.0, elev=30.0, size_sphere=2.0, dst_file='')[source]#
Display the binary tree.
- Parameters:
azim (float) – viewing angle -> azimuth (default:-40)
elev (float) – viewing angle -> elevation (default:30)
size_sphere (float) – size of each single sphere.
dst_file (Union[Path, str]) – name of the destination file, leave blank to not save the plot.
- Return type:
None
- qutree.bloch_points(xp, yp, zp, colors, ax=None, azim=-40.0, elev=30.0)[source]#
Plot points on a bloch spere.
- Parameters:
xp (ndarray) – array of the x axis coordinate
yp (ndarray) – array of the y axis coordinate
zp (ndarray) – array of the z axis coordinate
colors – array of colors for each point
ax (Optional[Axes]) – ax where the Bloch Sphere will be plotted, if None one is created
azim (float) – azimuth to plot the sphere
elev (float) – azimuth to plot the sphere
- Return type:
None
- qutree.fun_recursive(psi, coord='', tree_vals=[], tree_idxs=[], tol=0.0001)[source]#
Recursive function going down the hilbert schmidt decomposition.
- Parameters:
psi (ndarray) – array representing the state in the current subspace \((2^N,M)\)
coord (str) – string representing the current coordinate in the binary tree
tree_vals (list) – register storing the \(\theta\) and \(\phi\) of the Bloch sphere at each coordinate
tree_idxs (list) – register storing the coordinates
tol (Optional[float]) – tolerance to delete a subspace.
- Returns:
phip – the global phases of the local subspace
n – the amplitude of the local subspace
tree_vals – register storing the \(\theta\) and \(\phi\) of the Bloch sphere at each coordinate
tree_idxs – register storing the coordinates
- Return type:
Tuple[ndarray, ndarray, list, list]
- qutree.nphi_psi(psi)[source]#
Decompose an array of complex into absolute value and angles.
- Parameters:
psi (ndarray) – array of complex values
- Returns:
r – array of absolute values
phi – array of angles from \([0, 2\pi]\)
- Return type:
Tuple[ndarray, ndarray]
- qutree.nthe_n0n1(n0, n1)[source]#
Carthesian to Polar.
Compute \(n\) and \(\theta\) such that \([n0,n1] = n[cos(\theta),sin(\theta)]\)
- Parameters:
n0 (ndarray) – array of absolute values
n1 (ndarray) – array of absolute values
- Returns:
n – array of norm
the – array of angles from \([0, \pi]\)
- Return type:
Tuple[ndarray, ndarray]
- qutree.phimp_phi01(phi0, phi1)[source]#
Go from two subspace phases to local and global phase.
- Parameters:
phi0 – array of subspace 0 phases
phi1 – array of subspace 1 phases
- Returns:
phig – array of global phases
phil – array of local phases
- qutree.thephi_to_xyz(the, phi)[source]#
Spherical to carthesian.
- Parameters:
the (ndarray) – array of the angles \([0,\pi]\)
phi (ndarray) – array of \(\phi\) angles \([0,2 \pi]\)
- Returns:
x – array of the x axis coordinate
y – array of the y axis coordinate
z – array of the z axis coordinate
- Return type:
Tuple[ndarray, ndarray, ndarray]