function matrix=remat(array,ilen);
%function matrix=remat(array,ilen);
% where ilen is number of rows (first arg  from size(matrix) )
%    or is a matrix to provide dimensions of new matrix
% inverse function of u=u(:);

if length(ilen)~=1 
      [ilen,jlen]=size(ilen);
else 
      jlen=length(array(:))/ilen;
end

matrix=( ones(ilen,1)*(0:jlen-1)*ilen+(1:ilen)'*ones(1,jlen) );
matrix(matrix)=array(:);
