#NEWLINE# @ experimental ( as_of = '0.4.0' ) #NEWLINE# def svd_rank( M_shape , S , tol = None ) : #NEWLINE# #INDENT# "Matrix rank of `M` given its singular values `S`.\n\n    See `np.linalg.matrix_rank` for a rationale on the tolerance\n    (we're not using that function because it doesn't let us reuse a\n    precomputed SVD)." #NEWLINE# if ( S is None ) : #NEWLINE# #INDENT# tol = ( ( S . max ( ) * max ( M_shape ) ) * np . finfo ( S . dtype ) . eps ) #NEWLINE# #UNINDENT# return np . sum ( ( S > tol ) )