gftool.matrix.decompose_her¶
-
gftool.matrix.
decompose_her
(her_mat, check=True) → gftool.matrix.UDecomposition[source]¶ Decompose Hermitian matrix her_mat into eigenvalues and (right) eigenvectors.
Decompose the her_mat into rv, eig, rv_inv, with her_mat = (rv * eig) @ rv_inv. This is the unitary similarity transformation:
\[M = U Λ U^†, Λ = diag(λ₀, λ₁, …)\]where \(λₗ\) are the eigenvalues and \(U\) the unitary matrix of right eigenvectors returned as rv with \(U^{-1} = U^†\). Internally, this is just a wrapper for
numpy.linalg.eigh
.- Parameters
- her_mat(…, N, N) complex np.ndarray
matrix to be decomposed
- checkbool, optional
If check, raise an error if her_mat is not Hermitian. (default: True)
- Returns
- Decomposition.rv(…, N, N) complex np.ndarray
The right eigenvectors \(U\)
- Decomposition.eig(…, N) complex np.ndarray
The complex eigenvalues of her_mat
- Decomposition.rv_inv(…, N, N) complex np.ndarray
The inverse of the right eigenvectors \(U\)
- Raises
- ValueError
If check=True and her_mat is not Hermitian.
Examples
Perform the eigendecomposition:
>>> matrix = np.random.random((10, 10)) + 1j*np.random.random((10, 10)) >>> her_mat = 0.5*(matrix + matrix.conj().T) >>> rv, eig, rv_inv = gt.matrix.decompose_her(her_mat) >>> np.allclose(her_mat, (rv * eig) @ rv_inv) True >>> np.allclose(rv @ rv.conj().T, np.eye(*her_mat.shape)) True
This can also be simplified using the
Decomposition
class>>> dec = gt.matrix.decompose_her(her_mat) >>> np.allclose(her_mat, dec.reconstruct()) True