function [omega na a]=selectmatreal(l,wl,wh)

% This function constructs AW matrix where the lowest L Fourier components
% are truncated. Note the truncation rule is specified in trun_rule.m file.

w=zeros(l,l);
for t=1:l
 for s=1:l
   if t==1
      w(t,s)= l^(-1/2);
   elseif t==l & mod(l,2)==0
      w(t,s)= l^(-1/2)*(-1)^(s+1);
   elseif mod(t,2)==0 %(even)
      w(t,s)= (2/l)^(1/2)*cos(pi*t*(s-1)/l);
   else    
      w(t,s)= (2/l)^(1/2)*sin(pi*(t-1)*(s-1)/l);
   end
 end
end

a=zeros(l,l);
if wl==0
    a(1,1)=1;
end

for j=2:l
    if mod(j,2)==0
        if wl<=j*pi/l & wh>=j*pi/l
        a(j,j)=1;
        end
    else 
        a(j,j)=a(j-1,j-1);
    end
end

omega=w'*a*w;
na=sum(diag(a));

