gftool.matrix.decompose_mat

gftool.matrix.decompose_mat(mat)gftool.matrix.Decomposition[source]

Decompose matrix mat into eigenvalues and (right) eigenvectors.

Decompose the mat into rv, eig, rv_inv, with mat = (rv * eig) @ rv_inv. This is the similarity transformation:

\[M = P Λ P^{-1}, Λ = diag(λ₀, λ₁, …)\]

where \(λₗ\) are the eigenvalues and \(P\) the matrix of right eigenvectors returned as rv. Internally, this is just a wrapper for numpy.linalg.eig.

Parameters
mat(…, N, N) complex np.ndarray

matrix to be decomposed

Returns
Decomposition.rv(…, N, N) complex np.ndarray

The right eigenvectors \(P\)

Decomposition.eig(…, N) complex np.ndarray

The complex eigenvalues of mat

Decomposition.rv_inv(…, N, N) complex np.ndarray

The inverse of the right eigenvectors \(P\)

Examples

Perform the eigendecomposition:

>>> matrix = np.random.random((10, 10))
>>> rv, eig, rv_inv = gt.matrix.decompose_mat(matrix)
>>> np.allclose(matrix, (rv * eig) @ rv_inv)
True
>>> np.allclose(rv @ rv_inv, np.eye(*matrix.shape))
True

This can also be simplified using the Decomposition class

>>> dec = gt.matrix.decompose_mat(matrix)
>>> np.allclose(matrix, dec.reconstruct())
True