function hatA = hat(A,M,N) % HAT Matrix in hat format % hatA = hat(A,M,N) constructs an (m+n) by (m+n) matrix % in which A occupies the first m rows and the first n % columns,in which the remaining columns of the first m % rows contains the m by m unimodular matrix M, in which % the remaining rows of the first n columns contains the % n by n unimodular matrix N, and in which the lower right % n by m corner contains only zeros except that the entry % in the lower left corner is m. % % See also UNHAT, NEWHAT. % Adapted from Harold M. Edwards, "Linear Algebra." % Written by Serge Tchikanda 02/13/96. [mA,nA]=size(A); [mM,nM]=size(M); [mN,nN]=size(N); if (mM ~=nM) | (mN ~=mN) disp(' ') disp('The last two inputs must be square matrices') end if (mA ~= mM) disp(' ') disp(' The first and second inputs must have the same number of rows') break end if (nA ~= nN) disp(' ') disp(' The first and third inputs must have the same number of columns') break end if (det(M) ~= 1) | (det(N) ~= 1) disp(' ') disp(' The last two inputs must be unimodular matrices') break end hatA = [A M;N zeros(nA,mA)]; [mh,nh]=size(hatA); hatA(mh,nh)=mA;