EigenDecomposition of a matrix

Hi guys, I am using pytorch to calculate the eigendecomposition of a matrix

>>> import torch
>>> a = torch.tensor([[1, 2, -2], [2, 1, -2], [2, 2, -3]], dtype=torch.float32)
>>> torch.linalg.eig(a)
eigenvalues=tensor([ 1.0000+0.j, -1.0000+0.j, -1.0000+0.j]),
eigenvectors=tensor([[-5.7735e-01+0.j, -3.4413e-08+0.j,  3.4246e-01+0.j],
        [-5.7735e-01+0.j,  7.0711e-01+0.j,  4.7068e-01+0.j],
        [-5.7735e-01+0.j,  7.0711e-01+0.j,  8.1313e-01+0.j]]))

Is there anyway to get the eigenvalues and the eigenvectors as whole number ??

if you mean as reals (as torch.linalg.eig returns them as dtype torch.complex64), you can just do

eigenvalues = torch.real(eigenvalues)
eigenvectors = torch.real(eigenvectors)

and that’ll convert them to reals