% Subroutine of rcompletePADM2.m

function x = formap(x,m,n,i,j)

L = min(i,j);

for r = 1:L-1
  x(:,n*(r-1)+1:n*r) = x(:,n*(r-1)+1:n*r)*r;
  x(:,n*(i+j-1-r)+1:n*(i+j-r)) = x(:,n*(i+j-1-r)+1:n*(i+j-r))*r;
end

r = L;
x(:,n*(L-1)+1:n*(i+j-L)) = x(:,n*(L-1)+1:n*(i+j-L))*r;
%for s = L:i+j-L
%  x(:,n*(s-1)+1:n*s) = x(:,n*(s-1)+1:n*s)*r;
%end

%y = x;