% One step of row-reduction
%$Id: debug1a.m,v 1.2 2017/03/26 20:53:40 mike Exp $

N=100;
M=1+rand(N,N);
originalDet=det(M);

for k=2:N
  %for j=1:N
  %  M(k,j)=M(k,j)-(M(k,1)/M(1,1))*M(1,j);
  %end
  % vectorized expression does not exhibit bug!  Tell why!
  M(k,:)=M(k,:)-(M(k,1)/M(1,1))*M(1,:);
end
newDet=det(M);
fprintf('Error in determinant=%g\n', ...
	abs(originalDet-newDet)/abs(originalDet) )

