<s> import numpy as np <EOL> from numpy . linalg import svd <EOL> def rank_est ( A , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> A = np . atleast_2d ( A ) <EOL> s = svd ( A , compute_uv = False ) <EOL> tol = max ( atol , rtol * s [ <NUM_LIT:0> ] ) <EOL> rank = int ( ( s >= tol ) . sum ( ) ) <EOL> return rank <EOL> def nullspace ( A , atol = <NUM_LIT> , rtol = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> A = np . atleast_2d ( A ) <EOL> u , s , vh = svd ( A ) <EOL> tol = max ( atol , rtol * s [ <NUM_LIT:0> ] ) <EOL> nnz = ( s >= tol ) . sum ( ) <EOL> ns = vh [ nnz : ] . conj ( ) . T <EOL> return ns </s>
