# Load MatrixUtils before! # All indices (of vectors, matrices) are assumed to start at 0 # B is assumed to be a list (otherwise replace B by B.list() ) def step_3(A,c,B,i): z = A.matrix_from_rows(B).solve_left(c) y = A.matrix_from_rows(B).solve_left(-A.row(i)) r = ratios(z,y) l = infinity j = -1 for k in range (A.ncols()): if (r[k] >= 0): if (r[k] < l): l = r[k] j = k if (j < 0): print "PL n'est pas admissible" return [] B[j] = i return B