eig#

ivy.eig(x, /, *, out=None)[source]#

Return an eigendecomposition x = QLQᵀ of a symmetric matrix (or a stack of symmetric matrices) x, where Q is an orthogonal matrix (or a stack of matrices) and L is a vector (or a stack of vectors).

Note

The function eig currently behaves like eigh, as it requires complex number support, once complex numbers are supported, x does not need to be a complex Hermitian or real symmetric matrix.

Parameters:

x (Union[Array, NativeArray]) – input array having shape (..., M, M) and whose innermost two dimensions form square matrices. Must have a floating-point data type.

Return type:

Tuple[Union[Array, NativeArray]]

Returns:

  • ret – a namedtuple (eigenvalues, eigenvectors) whose

    • first element must have the field name eigenvalues (corresponding to L above) and must be an array consisting of computed eigenvalues. The array containing the eigenvalues must have shape (..., M).

    • second element have have the field name eigenvectors (corresponding to Q above) and must be an array where the columns of the inner most matrices contain the computed eigenvectors. These matrices must be orthogonal. The array containing the eigenvectors must have shape (..., M, M).

    • Each returned array must have the same floating-point data type as x.

  • .. note:: – Eigenvalue sort order is left unspecified and is thus implementation-dependent.

Array.eig(self, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.eig. This method simply wraps the function, and so the docstring for ivy.eig also applies to this method with minimal changes.

Return type:

Tuple[Array]

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> x.eig()
(
ivy.array([-0.37228132+0.j,  5.37228132+0.j]),
ivy.array([[-0.82456484+0.j, -0.41597356+0.j],
           [ 0.56576746+0.j, -0.90937671+0.j]])
)
Container.eig(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.eig. This method simply wraps the function, and so the docstring for ivy.eig also applies to this method with minimal changes.

Parameters:

x – container with input arrays.

Return type:

Container

Returns:

ret – container including arrays corresponding eigenvealues and eigenvectors of input arrays

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container({'x':{'xx':x}})
>>> c.eig()
{
    x:  {
            xx: (tuple(2), <class ivy.array.array.Array>, shape=[2, 2])
        }
}
>>>c.eig()['x']['xx']
(
    ivy.array([-0.37228107+0.j,  5.3722816 +0.j]),
    ivy.array([
            [-0.8245648 +0.j, -0.41597357+0.j],
            [0.56576747+0.j, -0.9093767 +0.j]
        ])
)