def inv_posdef(mat):
    """Stable inverse of a positive definite matrix."""
    # See:
    # - http://www.seas.ucla.edu/~vandenbe/103/lectures/chol.pdf
    # - http://scicomp.stackexchange.com/questions/3188
    chol = np.linalg.cholesky(mat)
    ident = np.eye(mat.shape[0])
    res = solve_triangular(chol, ident, lower=True, overwrite_b=True)
    return np.transpose(res).dot(res)
def inv_posdef ( mat ) : chol = np . linalg . cholesky ( mat ) ident = np . eye ( mat . shape [ 0 ] ) res = solve_triangular ( chol , ident , lower = True , overwrite_b = True ) return np . transpose ( res ) . dot ( res )
Stable inverse of a positive definite matrix.