Hello Leo!



 Leockl:

Using PyTorch, I am wanting to work out the square root of a positive semi-definite matrix.


Perform the eigendecomposition of your matrix and then take the
square-root of your eigenvalues.  (If any of your eigenvalues of your
semi-definite matrix show up as numerically negative, replace them
with zero.)
For more detail, see this post:

  
    
    
    Raising a tensor to a fractional power 
  
  
    Hi mmutic! 

A standard approach to exponentiating a matrix is to calculate its 
eigendecomposition and then exponentiate the eigenvalues. 
Here is a pytorch version 0.3.0 script that illustrates this: 
import torch
print (torch.__version__)

m = torch.FloatTensor([[.5,.5],[.7,.9]])           # original matrix

# desired result
mres = torch.FloatTensor ([[ 2.69776664, -1.10907208], [-1.55270001,  1.81051025]])

evals, evecs = torch.eig (m, eigenvectors = True)  # get eigendecomposition
evals = e…
  


Best.
K. Frank