def rank_est(A, atol=1e-13, rtol=0):
 A = np.atleast_2d(A)
 s = svd(A, compute_uv=False)
 tol = max(atol, (rtol * s[0]))
 rank = int((s >= tol).sum())
 return rank

def rank_est ( A , atol = 1e-13 , rtol = 0 ) : A = np . atleast_2d ( A ) s = svd ( A , compute_uv = False ) tol = max ( atol , ( rtol * s [ 0 ] ) ) rank = int ( ( s >= tol ) . sum ( ) ) return rank
estimate the rank of a matrix .