function t = diagonalize(t,e,l,tol) % % returns a diagonalized tableau after e has entered and l % has left the basis. % % on entry: % t linear programming problem in standard format; % e variable entering the basis is column index; % l variable leaving the basis is row (-1) index; % tol tolerance used to decide whether number is zero. % % on return: % t linear programming problem in standard format, % with t(l+1,e) = 1. % nr = size(t,1); % number of rows; nc = size(t,2); % number of columns; p = t(l+1,e); % pivot for j=1:nc t(l+1,j) = t(l+1,j)/p; % divide (l+1)-th row by pivot end; for i=1:nr % make zeros if ((i~=l+1) & (abs(t(i,e)) > tol)) p = t(i,e); for j=1:nc t(i,j) = t(i,j) - p*t(l+1,j); end; end; end;