%D_gen_wp_cons_L1P
%Discrete wavelets of 1 level

lole1=input('loglength of signal;0--former; ?')
if lole1>0
    lole=lole1;
    N=2^lole;
    nu=0:N-1;
    si=sin(pi*nu/N);
    co=cos(pi*nu/N);
end
shi=1;%input('shift to the center--1; ?')

%Par1=[2:2:10];%input('spline orders;0--former; ?')
Par1=[2 4 10];%input('spline orders;0--former; ?')
if Par1>0
    Par=Par1;
end


SP0=[];fSP0=[];
SP1=[];fSP1=[];
for kk=1:3
    P=Par(kk);
    [~, ~, ~, U2]=per_dbspP(N,1,2*P);
  U2=[U2 U2];  
   % rho=Rho(kk);
fspli0=si.^P./sqrt(U2);
spli0=real(ifft(fspli0));
spli0=circ_h(spli0,N/4);
SP0=[SP0;spli0];
fSP0=[fSP0;fspli0];
[fspli1]=co.^P./sqrt(U2);
spli1=real(ifft(fspli1));
spli1=circ_h(spli1,3*N/4);
SP1=[SP1;spli1];
fSP1=[fSP1;abs(fspli1)];
end
x=(1:N)-N/2;
y=x;

figure;
for kk=1:3
eval(['subplot(3,2,' int2str(2*kk-1) ')'])
a0=[SP0(kk,:) ];
plot(y,a0,'LineWidth',2);hold on
a1=[SP1(kk,:) ];
plot(y,a1,'--','LineWidth',2);
hold off
     title(['\fontsize{16}Spline order: '  int2str(Par(kk))])
set(gca,'FontSize',16)
 axis([y(1) y(end) -.5 1])
 set(gca,'XTickLabel',{})
eval(['subplot(3,2,' int2str(2*kk) ')'])
a0=[fSP0(kk,:) ];
a0=circshift(a0',N/2)';
plot(a0,'LineWidth',2);hold on
a1=[fSP1(kk,:) ];
a1=circshift(a1',N/2)';
plot(a1,'--','LineWidth',2);hold off

     title(['\fontsize{16}Spline order: '  int2str(Par(kk))])

 axis([1,N+1, 0 2])
set(gca,'XTick',[1: N/4:N])
%set(gca,'XTickLabel',{'-2\pi','-\pi','0','pi','2pi'})
set(gca,'XTickLabel',{'-N/2','-N/4','0','N/4','N/2'})
set(gca,'FontSize',16)

end
