示例#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
示例#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
示例#3
0
文件: tools.py 项目: ejacob24/pyhmmtb
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
示例#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