eigh

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.

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

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

Return type

out_value(Tensor)

Examples

import numpy as np
import paddle

x_data = np.array([[1, -2j], [2j, 5]])
x = paddle.to_tensor(x_data)
out_value, out_vector = paddle.linalg.eigh(x, UPLO='L')
print(out_value)
#[0.17157288, 5.82842712]
print(out_vector)
#[(-0.9238795325112867+0j), (-0.3826834323650898+0j)],
#[ 0.3826834323650898j    , -0.9238795325112867j    ]]