(ctx, A, b, **kwargs)
Ax = b => x

        Solve a symmetric positive-definite linear equation system.
        This is twice as efficient as lu_solve.

        Typical use cases:
        * A.T*A
        * Hessian matrix
        * differential equations
Ax = b => x
Ax = b = > x
def cholesky_solve(ctx, A, b, **kwargs):
        """
        Ax = b => x

        Solve a symmetric positive-definite linear equation system.
        This is twice as efficient as lu_solve.

        Typical use cases:
        * A.T*A
        * Hessian matrix
        * differential equations
        """
        prec = ctx.prec
        try:
            ctx.prec += 10
            # do not overwrite A nor b
            A, b = ctx.matrix(A, **kwargs).copy(), ctx.matrix(b, **kwargs).copy()
            if A.rows !=  A.cols:
                raise ValueError('can only solve determined system')
            # Cholesky factorization
            L = ctx.cholesky(A)
            # solve
            n = L.rows
            if len(b) != n:
                raise ValueError("Value should be equal to n")
            for i in xrange(n):
                b[i] -= ctx.fsum(L[i,j] * b[j] for j in xrange(i))
                b[i] /= L[i,i]
            x = ctx.U_solve(L.T, b)
            return x
        finally:
            ctx.prec = prec
def cholesky_solve ( ctx , A , b , * * kwargs ) : prec = ctx . prec try : ctx . prec += 10 # do not overwrite A nor b A , b = ctx . matrix ( A , * * kwargs ) . copy ( ) , ctx . matrix ( b , * * kwargs ) . copy ( ) if A . rows != A . cols : raise ValueError ( 'can only solve determined system' ) # Cholesky factorization L = ctx . cholesky ( A ) # solve n = L . rows if len ( b ) != n : raise ValueError ( "Value should be equal to n" ) for i in xrange ( n ) : b [ i ] -= ctx . fsum ( L [ i , j ] * b [ j ] for j in xrange ( i ) ) b [ i ] /= L [ i , i ] x = ctx . U_solve ( L . T , b ) return x finally : ctx . prec = prec