Hello Leo!



 Leockl:

if one can do this elegantly like what you have proposed, then why are people working on a PyTorch function for this which involves more complicated math/algorithms, for eg. in this Github link below especially when you see the more recent comments from the last couple of days?


First comment:
The code Yaroslav posted at the beginning of the github issue to which
you linked is basically what I suggested.  He (properly) treats the null
space of the semi-definite matrix more carefully, and he (properly) uses
torch.symeig() rather than torch.eig().
Second comment:
More importantly, I’m not an expert, but I have no reason to believe that
eigendecomposition is the best algorithm for the root of a matrix.  The
github issue discusses other approaches that could be faster and/or
numerically more stable or accurate.
The eigendecomposition contains, in a sense, more information than
the root, so it could well be more expensive to calculate.  By way of
analogy, you can use eigendecomposition to calculate the inverse of
a matrix (take the reciprocals of the eigenvalues), but it is not the
preferred matrix-inverse algorithm.
Best.
K. Frank