Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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