paddle.linalg. eigvals ( x, name=None ) [source]

Compute the eigenvalues of one or more general matrices.


The gradient kernel of this operator does not yet developed. If you need back propagation through this operator, please replace it with paddle.linalg.eig.

  • x (Tensor) – A square matrix or a batch of square matrices whose eigenvalues will be computed. Its shape should be [*, M, M], where * is zero or more batch dimensions. Its data type should be float32, float64, complex64, or complex128.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.


Tensor, A tensor containing the unsorted eigenvalues which has the same batch dimensions with x. The eigenvalues are complex-valued even when x is real.


>>> import paddle
>>> paddle.seed(2023)

>>> x = paddle.rand(shape=[3, 3], dtype='float64')
>>> print(x)
Tensor(shape=[3, 3], dtype=float64, place=Place(cpu), stop_gradient=True,
[[0.86583615, 0.52014721, 0.25960938],
 [0.90525323, 0.42400090, 0.40641288],
 [0.97020893, 0.74437359, 0.51785128]])

>>> print(paddle.linalg.eigvals(x))
Tensor(shape=[3], dtype=complex128, place=Place(cpu), stop_gradient=True,
[ (1.788956694280852+0j)  ,  (0.16364484879581526+0j),