paddle.linalg. eig ( x, name=None ) [source]

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


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

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

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

  • This API is only supported on CPU device.

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

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

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


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

Return type



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)
# Tensor(shape=[3, 3], dtype=complex128, place=CPUPlace, stop_gradient=False,
#       [[(-0.5061363550800655+0j) , (-0.7971760990842826+0j) ,
#         (0.18518077798279986+0j)],
#        [(-0.8308237755993192+0j) ,  (0.3463813401919749+0j) ,
#         (-0.6837005269141947+0j) ],
#        [(-0.23142567697893396+0j),  (0.4944999840400175+0j) ,
#         (0.7058765252952796+0j) ]])

# Tensor(shape=[3], dtype=complex128, place=CPUPlace, stop_gradient=False,
#       [ (16.50471283351188+0j)  , (-5.5034820550763515+0j) ,
#         (-0.21026087843552282+0j)])