% DRAFT_GE  Draft of loops to implement Gaussian Elimination.
% (Make into function on augmented matrix Ab.  Needs back sub too.)

for i = 1:n-1         % columns in which to make zeros (except last, where no work needed)
  p = i;
  while Ab(i,p) == 0
    if p == n, error('no soln'), end
    p = p+1;
  end
  if p > i
    tmp = Ab(i,:);
    Ab(i,:) = Ab(p,:);
    Ab(p,:) = tmp;
  end
  for j = i+1:n       % rows below diagonal (pivot) position
    m = Ab(j,i) / Ab(i,i);  % NOTE: division!
    Ab(j,:) = Ab(j,:) - m * Ab(i,:);  % E_j <- E_j - # E_i
  end
end 

