def isposdef(a): """ % ISPOSDEF Test for positive definite matrix. % ISPOSDEF(A) returns 1 if A is positive definite, 0 otherwise. % Using chol is much more efficient than computing eigenvectors. % From Tom Minka's lightspeed toolbox """ try: cholesky(a) return True except LinAlgError: return False
def isposdef(a): ''' % ISPOSDEF Test for positive definite matrix. % ISPOSDEF(A) returns 1 if A is positive definite, 0 otherwise. % Using chol is much more efficient than computing eigenvectors. % From Tom Minka's lightspeed toolbox ''' try: cholesky(a) return True except LinAlgError: return False
def logdet(A): ''' % log(det(A)) where A is positive-definite. % This is faster and more stable than using log(det(A)). % From Tom Minka's lightspeed toolbox ''' U = cholesky(A).T; y = 2*np.sum(np.log(np.diag(U)),0) return y
def logdet(A): ''' % log(det(A)) where A is positive-definite. % This is faster and more stable than using log(det(A)). % From Tom Minka's lightspeed toolbox ''' U = cholesky(A).T y = 2 * np.sum(np.log(np.diag(U)), 0) return y