scqubits.core.diag.esys_scipy_sparse#

scqubits.core.diag.esys_scipy_sparse(matrix, evals_count, **kwargs)[source]#

Diagonalization based on scipy’s (sparse) eigsh function. Both evals and evecs are returned.

Note the convoluted convention when it comes to ordering and how it is related to the presence of return_eigenvectors parameter. See here for details: https://github.com/scipy/scipy/issues/9082

This function ensures that: 1. We always use the same “random” starting vector v0. Otherwise results show random behavior (small deviations between different runs, problem for pytests) 2. We test for degenerate eigenvalues. If there are any, we orthogonalize the eigenvectors properly.

Todo

Right now, this is essentially a copy/paste of spectrum_utils.eigsh_safe(). When the dust settles, should combine both into one.

Parameters:
  • matrix (Union[ndarray, csc_matrix, Qobj]) – ndarray or qutip.Qobj to be diagonalized

  • evals_count (int) – how many eigenvalues/vectors should be returned

  • kwargs – optional settings that are passed onto the diagonalization routine

Return type:

Union[Tuple[ndarray, ndarray], Tuple[ndarray, QutipEigenstates]]

Returns:

a tuple of eigenvalues and eigenvectors. Eigenvectors are Qobjs if matrix is a Qobj instance