function coef = convol(n,r)

% Compute the coefficients for the generalized Jackson kernel
%    K_{m,2r}, see (4.2).
% n:    the size of the Toeplitz matrix T;
% r:    2, 3 or 4;
% coef: the coefficients {b_k^(m,r):|k|<=r(m-1)} of
%           the generalized Jackson kernel K_{m,2r}.

m = floor(n/r);
a = 1:-1/m:1/m;

r0 = 1;
coef = [a(m:-1:2) a];
while r0 < r
   M = (2*r0+3)*m;
   b1 = zeros(M,1);
   c = zeros(M,1);
   c(1:m) = a;
   c(M:-1:M-m+2) = a(2:m);
   b1(m:m+2*r0*(m-1)) = coef;
   tp = ifft(fft(b1).*fft(c));
   coef = real(tp(1:2*(r0+1)*(m-1)+1));
   r0 = r0+1;
end
M = r*(m-1)+1;
coef = [coef(M:-1:1)' zeros(1,n-M)]';
coef = coef';
