function [es,ws,sp]=malvar_aux(s,k,m);

%Programme auxiliaire pour la routine merge. 

N=(2^k+1)*2^m;
NN=(2^k-1)*2^m;
MM=2^m;
t=1:MM;
theta=[sin(pi*t/2^(m+1)) ones(1,NN) cos(pi*t/2^(m+1))];
ws=s.*theta;
ws=[ws zeros(1,2^(m+k+2)-N+1)];
wshat=conj(fft(ws)*sqrt(1/2^(m+k-1)));
wshat=wshat(1:2^(m+k+1));
tt=0:2^(m+k+1)-1;
ttt=mod(tt,2);
wshat=ttt.*wshat;
l=0:2^(k+m+1)-1;
e=exp(-i*pi*l/2^(k+2));
wshat=imag(e.*wshat);
ws1=s.*theta;
sp=wshat(2:2:2^(m+k+1));
w=sp.^2;
mm=max(abs(w)); 
if mm>.00001,
  y=-(w.*(log (w)))';
  es=sum(y);
else 
   es=0; 
end; 
wshat=[wshat zeros(1,2^(m+k+1))];
iwshat=2^(k+m+2)*imag(ifft(wshat));
iwshat2=iwshat(1:N-2^(m-1));
iwshat1=iwshat(2^(m+k+2)-2^(m-1)+1:2^(m+k+2));
ws=[iwshat1 iwshat2];
ws=(ws.*theta)*sqrt(1/2^(k+m-1));