function coef = jackson(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}.
% The code obtain the coefficients by interpoltating on K_{m,2r}
%   which is not the same as the method presented in the book.

    m = floor(n / r);
    k = 2 ^ nextpow2(2 * r * (m - 1) + 1);
    a = (m : -1 : 1) / m;
    coef = [ a zeros(1, k - 2 * m + 1) a(end : -1 : 2) ];
    coef = real(fft(coef)).^r; % evaluate K_{m,2r}((2 j pi/k) = [K_{m,2}((2j-1)pi/(2k))]^r, j = 0,1,2,...,k-1
%    coef = ifft(real(fft(coef)) .^ r, 'symmetric');
    coef = real(ifft(coef));  % compute the coefficients of the interpolating polynomial by using fast Fourier transform.
    M = r * (m - 1) + 1;
    coef = [ coef(1 : M) zeros(1, n - M) ];