paddle.linalg. eigh ( x, UPLO='L', name=None ) [source]

Compute the eigenvalues and eigenvectors of a complex Hermitian (conjugate symmetric) or a real symmetric matrix.

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

  • UPLO (str, optional) – (string, default ‘L’), ‘L’ represents the lower triangular matrix, “‘U’ represents the upper triangular matrix.”. Default: ‘L’.

  • 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.


2-element tuple containing

  • out_value(Tensor): A Tensor with shape \([*, N]\) and data type of float32 and float64. The eigenvalues of eigh op.

  • out_vector(Tensor): A Tensor with shape \([*, N, N]\) and data type of float32, float64, complex64 and complex128. The eigenvectors of eigh op.


>>> import paddle

>>> x = paddle.to_tensor([[1, -2j], [2j, 5]])
>>> out_value, out_vector = paddle.linalg.eigh(x, UPLO='L')
>>> print(out_value)
Tensor(shape=[2], dtype=float32, place=Place(cpu), stop_gradient=True,
[0.17157286, 5.82842731])
>>> print(out_vector)
Tensor(shape=[2, 2], dtype=complex64, place=Place(cpu), stop_gradient=True,
[[(-0.9238795042037964+0j), (-0.3826833963394165+0j)],
 [ 0.3826833963394165j    , -0.9238795042037964j    ]])