There is a poste on checking if a matrix is PSD in Python. I am wondering how we can check it in PyTorch? is there a function for that?
Haven't found a PyTorch function for that, but you should be able to determine it easily, and similarly to the post you've linked, by checking whether the matrix is symmetric and all eigenvalues are non-negative:
def is_psd(mat):
return bool((mat == mat.T).all() and (torch.linalg.eigvals(mat).real>=0).all())
#Test:
is_psd(torch.randn(2,2))