def is_pos_def(A):
if np.array_equal(A, A.T): # Test the symmetry of the matrix.
try:
np.linalg.cholesky(A) # Test if it is positive definite.
return True
except LinAlgError:
return False
else:
return False