function outmat = permMat(n, row1, row2)
% function outmat = permMat(n, row1, row2)
%
% Generates a permutation matrix for row exchanges in Gaussian elimination
%
%  Inputs:      n   The matrix generated will be square, with <n> rows/cols
%      row1, row2   The row numbers which are to be permuted/exchanged
%                   when some matrix is multiplied on the left by <outmat>.
%                   When a matrix is multiplied on the right by <outmat>,
%                   the result is a swap of columns, not rows.
%
%  Output:   outmat   This is the desired permutation matrix

 I = eye(n);
 outmat = I;
 outmat(row1, :) = I(row2, :);
 outmat(row2, :) = I(row1, :);
end
