eigvalsh

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

Computes the eigenvalues of a complex Hermitian (conjugate symmetric) or a real symmetric matrix.

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

  • UPLO (str, optional) – Lower triangular part of a (‘L’, default) or the upper triangular part (‘U’).

  • 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

The tensor eigenvalues in ascending order.

Return type

Tensor

Examples

import numpy as np
import paddle

x_data = np.array([[1, -2j], [2j, 5]])
x = paddle.to_tensor(x_data)
out_value = paddle.eigvalsh(x, UPLO='L')
print(out_value)
#[0.17157288, 5.82842712]