eig

paddle.linalg. eig ( x, name=None ) [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, 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.

Returns

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

Eigenvalues(Tensors)

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.5061365365982056+0j) ,  (0.7971761226654053+0j) ,
   (0.1851806491613388+0j) ],
 [ (0.8308236598968506+0j) , (-0.3463813066482544+0j) ,
   (-0.6837005615234375+0j) ],
 [ (0.23142573237419128+0j), (-0.49449989199638367+0j),
   (0.7058765292167664+0j) ]])

>>> print(w)
Tensor(shape=[3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[ (16.50470733642578+0j)  , (-5.503481388092041+0j)  ,
  (-0.21026138961315155+0j)])