eig

paddle.linalg. eig ( x: Tensor, name: str | None = None ) → tuple[Tensor, Tensor] [source]

Performs the eigenvalue decomposition of a square matrix or a batch of square matrices.

Note

  • If the matrix is a Hermitian or a real symmetric matrix, please use eigh instead, which is much faster.

  • If only eigenvalues is needed, please use eigvals instead.

  • If the matrix is of any shape, please use svd.

  • This API is only supported on CPU device.

  • The output datatype is always complex for both real and complex input.

Parameters
  • x (Tensor) – A tensor with shape math:[*, N, N], The data type of the x should be one of float32, float64, complex64 or complex128.

  • name (str|None, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to api_guide_Name.

Returns

A tensor with shape math:[*, N] refers to the eigen values. Eigenvectors(Tensor): A tensor with shape math:[*, N, N] refers to the eigen vectors.

Return type

Eigenvalues(Tensor)

Examples

>>> import paddle

>>> x = paddle.to_tensor(
...     [
...         [1.6707249, 7.2249975, 6.5045543],
...         [9.956216, 8.749598, 6.066444],
...         [4.4251957, 1.7983172, 0.370647],
...     ]
... )
>>> w, v = paddle.linalg.eig(x)
>>> print(v)
Tensor(shape=[3, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[[ (0.50613654+0.00000000j),  (0.79717612+0.00000000j),
   (0.18518065+0.00000000j)],
 [ (0.83082366+0.00000000j), (-0.34638131+0.00000000j),
  (-0.68370056+0.00000000j)],
 [ (0.23142573+0.00000000j), (-0.49449989+0.00000000j),
   (0.70587653+0.00000000j)]])

>>> print(w)
Tensor(shape=[3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[(16.50470734+0.00000000j), (-5.50348139+0.00000000j),
 (-0.21026139+0.00000000j)])