def _pivot_row(T, pivcol, phase, tol=1e-12):
 if (phase == 1):
  k = 2
 else:
  k = 1
 ma = np.ma.masked_where((T[:(- k), pivcol] <= tol), T[:(- k), pivcol], copy=False)
 if (ma.count() == 0):
  return (False, np.nan)
 mb = np.ma.masked_where((T[:(- k), pivcol] <= tol), T[:(- k), (-1)], copy=False)
 q = (mb / ma)
 return (True, np.ma.where((q == q.min()))[0][0])

def _pivot_row ( T , pivcol , phase , tol = 1e-12 ) : if ( phase == 1 ) : k = 2 else : k = 1 ma = np . ma . masked_where ( ( T [ : ( - k ) , pivcol ] <= tol ) , T [ : ( - k ) , pivcol ] , copy = False ) if ( ma . count ( ) == 0 ) : return ( False , np . nan ) mb = np . ma . masked_where ( ( T [ : ( - k ) , pivcol ] <= tol ) , T [ : ( - k ) , ( - 1 ) ] , copy = False ) q = ( mb / ma ) return ( True , np . ma . where ( ( q == q . min ( ) ) ) [ 0 ] [ 0 ] )
given a linear programming simplex tableau .