colour.algebra.eigen_decomposition#
- colour.algebra.eigen_decomposition(a: ArrayLike, eigen_w_v_count: int | None = None, descending_order: bool = True, covariance_matrix: bool = False) Tuple[NDArrayFloat, NDArrayFloat][source]#
Compute the eigenvalues \(w\) and eigenvectors \(v\) of the specified array \(a\) in the specified order.
- Parameters:
a (ArrayLike) – Array to compute the eigenvalues \(w\) and eigenvectors \(v\) for.
eigen_w_v_count (int | None) – Number of eigenvalues \(w\) and eigenvectors \(v\) to return.
descending_order (bool) – Whether to return the eigenvalues \(w\) and eigenvectors \(v\) in descending order.
covariance_matrix (bool) – Whether to compute the eigenvalues \(w\) and eigenvectors \(v\) of the array \(a\) covariance matrix \(A = a^T \cdot a\).
- Returns:
Tuple of eigenvalues \(w\) and eigenvectors \(v\). The eigenvalues are in the specified order, each repeated according to its multiplicity. The column
v[:, i]is the normalized eigenvector corresponding to the eigenvaluew[i].- Return type:
Examples
>>> a = np.diag([1, 2, 3]) >>> w, v = eigen_decomposition(a) >>> w array([ 3., 2., 1.]) >>> v array([[ 0., 0., 1.], [ 0., 1., 0.], [ 1., 0., 0.]]) >>> w, v = eigen_decomposition(a, 1) >>> w array([ 3.]) >>> v array([[ 0.], [ 0.], [ 1.]]) >>> w, v = eigen_decomposition(a, descending_order=False) >>> w array([ 1., 2., 3.]) >>> v array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) >>> w, v = eigen_decomposition(a, covariance_matrix=True) >>> w array([ 9., 4., 1.]) >>> v array([[ 0., 0., 1.], [ 0., 1., 0.], [ 1., 0., 0.]])