qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec.simulate. density_matrix_diagonal  (  rho ,  axis=1  )[source]

The diagonal of the density matrix $\operatorname{diag}(\rho)$.

Parameters:
rhoarray_like

The density matrix $\rho$. Must have the same size in axis and axis + 1.

axisint

The axis along which the population is aligned in rho. The default is axis = 1, expecting rho as an array with shape (n, Atom.size, Atom.size, ... ).

Returns:
rho_diagndarray[floating]

The diagonal of the density matrix as an array with shape (n, Atom.size, ...).

Raises:
ValueError

If rho has less than axis + 2 dimensions or different sizes in the axes axis and axis + 1.