-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
Currently the return value of torch.eig is:
eigenvalues (Tensor):
Shape (n \times 2)(n×2) . Each row is an eigenvalue of input, where the first element is
the real part and the second element is the imaginary part. The eigenvalues are not
necessarily ordered.
eigenvectors (Tensor):
If eigenvectors=False, it’s an empty tensor. Otherwise, this
tensor of shape (n \times n)(n×n) can be used to compute normalized (unit length)
eigenvectors of corresponding eigenvalues as follows. If the corresponding eigenvalues[j]
is a real number, column eigenvectors[:, j] is the eigenvector corresponding to eigenvalues[j].
If the corresponding eigenvalues[j] and eigenvalues[j + 1] form a complex conjugate pair,
then the true eigenvectors can be computed as
\text{true eigenvector}[j] = eigenvectors[:, j] + i \times eigenvectors[:, j + 1]true eigenvector[j]=eigenvectors[:,j]+i×eigenvectors[:,j+1] ,
\text{true eigenvector}[j + 1] = eigenvectors[:, j] - i \times eigenvectors[:, j + 1]true eigenvector[j+1]=eigenvectors[:,j−i×eigenvectors[:,j+1] .
This behavior is because of historical reason when complex tensors was not a thing. Since complex tensor is now supported,
the return value of eigenvalues should then be a complex tensor of shape (n,), and eigenvectors should also be a complex tensor of shape (n,n) where eignvectors[:,j] is the jth eigen vector.
cc @ezyang @anjali411 @dylanbespalko @mruberry @gchanan @vincentqb @vishwakftw @jianyuh @nikitaved @pearu