%function [rmat,dl,dri] = frotmat(mat,nblk,blk,blkp,rpp,dl,dri)
%	Performs a unitary rotation of mat.  Called by muappr.

 function [rmat,dl,dri] = frotmat(mat,nblk,blk,blkp,rpp,dl,dri)
 [nr nc] = size(mat);
 il = eye(nr);
 ir = eye(nc);
 for i=1:length(rpp)
    row = mat(blkp(rpp(i),2):blkp(rpp(i)+1,2)-1,:);
    col = mat(:,blkp(rpp(i),1):blkp(rpp(i)+1,1)-1);
    w = row*row' - col'*col;
    [u,lam] = eig(w);
tp=dl(blkp(rpp(i),2):blkp(rpp(i)+1,2)-1,blkp(rpp(i),2):blkp(rpp(i)+1,2)-1);
dl(blkp(rpp(i),2):blkp(rpp(i)+1,2)-1,blkp(rpp(i),2):blkp(rpp(i)+1,2)-1)=u'*tp;
tp=dri(blkp(rpp(i),1):blkp(rpp(i)+1,1)-1,blkp(rpp(i),1):blkp(rpp(i)+1,1)-1);
dri(blkp(rpp(i),1):blkp(rpp(i)+1,1)-1,blkp(rpp(i),1):blkp(rpp(i)+1,1)-1)=tp*u;
il(blkp(rpp(i),2):blkp(rpp(i)+1,2)-1,blkp(rpp(i),2):blkp(rpp(i)+1,2)-1)=u';
ir(blkp(rpp(i),1):blkp(rpp(i)+1,1)-1,blkp(rpp(i),1):blkp(rpp(i)+1,1)-1)=u;
   end
 end
 rmat = il*mat*ir;

%
% Copyright MUSYN INC 1991,  All Rights Reserved
