geometric/step.py
def force_positive_definite(H):
    """
    Force all eigenvalues to be positive.
    """
    # Sorted eigenvalues and corresponding eigenvectors of the Hessian
    Hvals, Hvecs = sorted_eigh(H, asc=True)
    Hs = np.zeros_like(H)
    for i in range(H.shape[0]):
        if Hvals[i] > 0:
            Hs += Hvals[i] * np.outer(Hvecs[:,i], Hvecs[:,i])
        else:
            Hs -= Hvals[i] * np.outer(Hvecs[:,i], Hvecs[:,i])
    return Hs

    Force all eigenvalues to be positive.
    
Force all eigenvalues to be positive.
Force all eigenvalues to be positive .
def force_positive_definite(H):
    Hvals, Hvecs = sorted_eigh(H, asc=True)
    Hs = np.zeros_like(H)
    for i in range(H.shape[0]):
        if Hvals[i] > 0:
            Hs += Hvals[i] * np.outer(Hvecs[:,i], Hvecs[:,i])
        else:
            Hs -= Hvals[i] * np.outer(Hvecs[:,i], Hvecs[:,i])
    return Hs
def force_positive_definite ( H ) : Hvals , Hvecs = sorted_eigh ( H , asc = True ) Hs = np . zeros_like ( H ) for i in range ( H . shape [ 0 ] ) : if Hvals [ i ] > 0 : Hs += Hvals [ i ] * np . outer ( Hvecs [ : , i ] , Hvecs [ : , i ] ) else : Hs -= Hvals [ i ] * np . outer ( Hvecs [ : , i ] , Hvecs [ : , i ] ) return Hs
Force all eigenvalues to be positive.
Force all eigenvalues to be positive .
"""
    Force all eigenvalues to be positive.
    """ # Sorted eigenvalues and corresponding eigenvectors of the Hessian
H