function [ef,mf,ms]=MERGE4_aux(x,L);

%Programme auxiliaire pour la routine MERGE2 

N=length(x);
ex=entropie(x);
r=R4(x);
d=D4(x);
if L==1
	efs=entropie(r);
	efd=entropie(d);
    if efs+efd < ex;
      ir=R4etoile(r); 
      id=D4etoile(d);
      ef=efs+efd;
      mf=[ir;id];
      ms=['R';'D'];
    else 
      ef=ex;
      mf=x;
      ms=['0'];
    end;
else
   [efs, mfs, mfss]=MERGE4_aux(r,L-1);
   [efd, mfd, mfdd]=MERGE4_aux(d,L-1);
   mf=[];
   ms=[];
   if efs+efd < ex
	  [nrs ncs]=size(mfs);
	  for i=1:nrs
	  [nrm ncm]=size(mf);
      ir=R4etoile(mfs(i,:));
      irr=['R' mfss(i,:)];
	    if ncm~=0
			if ncm < length(ir)
				ir=ir(1:ncm);
			else
				ir=[ir zeros(1,(ncm-length(ir)))];
			end;
	    end;
      mf=[mf;ir];
      ms=[ms; irr];
	  end;	
	  [nrd ncd]=size(mfd);
	  for i=1:nrd
	  [nrm ncm]=size(mf);
      id=D4etoile(mfd(i,:));
      idd=['D' mfdd(i,:)];
	    if ncm ~= 0
			if ncm < length(id)
				id=id(1:ncm);
			else
				id=[id zeros(1,(ncm-length(id)))];
		    end;
	    end;
      mf=[mf;id];
      ms=[ms;idd];
	  end;	
	  ef=efs+efd;	
   else
   ef=ex;
   mf=x; 
   for k=1:L,
      ms=['0' ms];
   end;
end;
end;