% Matlab code gecp.m
% For "Applied Numerical Linear Algebra", Question 2.14
% Written by James Demmel, Modified, Jun 8 1997, Sept 25 2004
%
% Gaussian elimination with complete pivoting
%
% function [pr,l,u,pc]=gecp(a)
%
% inputs:
% a - square matrix
%
% outputs:
% pr - permutation matrix
% l - unit lower triangular matrix
% u - upper triangular matrix
% pc - permutation matrix
% (on output pr*l*u*pc' = a, modulo roundoff)

function [pr,l,u,pc]=gecp(a)