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]#
Return the eigen-values \(w\) and eigen-vectors \(v\) of given array \(a\) in given order.
- Parameters:
a (ArrayLike) – Array to return the eigen-values \(w\) and eigen-vectors \(v\) for
eigen_w_v_count (int | None) – Eigen-values \(w\) and eigen-vectors \(v\) count.
descending_order (bool) – Whether to return the eigen-values \(w\) and eigen-vectors \(v\) in descending order.
covariance_matrix (bool) – Whether to compute the eigen-values \(w\) and eigen-vectors \(v\) of the array \(a\) covariance matrix \(A =a^T\cdot a\).
- Returns:
Tuple of eigen-values \(w\) and eigen-vectors \(v\). The eigenv-alues are in given order, each repeated according to its multiplicity. The column
v[:, i]
is the normalized eigen-vector corresponding to the eige-nvaluew[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.]])