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]\) , where * is zero or greater batch dimension. 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 paddle

>>> x = paddle.to_tensor([[1, -2j], [2j, 5]])
>>> out_value = paddle.eigvalsh(x, UPLO='L')
>>> print(out_value)
Tensor(shape=[2], dtype=float32, place=Place(cpu), stop_gradient=True,
[0.17157286, 5.82842731])