function [gev,ev] = genevs(t,pchoice)

% Compute the eigenvalues of the circulant matrix in which T is embedded
%    and the eigenvalues of circulant preconditioner C.
% t:       the first column of the Toeplitz matrix T;
% pchoice: choice of preconditioner;
% gev:     the eigenvalues of the circulant matrix in which
%          the Toeplitz matrix T is imbedded;
% ev:      the eigenvalues of the circulant preconditioner C.

n   = length(t);
t1  = conj(t(n:-1:2));   % last column of T
gev = real(fft([t 0 t1].'));

if pchoice == 1       % T. Chan's preconditioner
    coef   = 1/n:1/n:1-1/n;
    ev     = fft([t(1) (1-coef).*t(2:n)+coef.*t1])';
elseif pchoice == 2   % Strang's preconditioner.
    ev     = fft([t(1:n/2) 0 conj(t(n/2:-1:2))].');
elseif pchoice == 3   % R. Chan's preconditioner
    ev     = fft([t(1) t(2:n)+t1].');
elseif pchoice == 4   % Modified Dirichlet kernel
    c    = [t(1) t(2:n)+t1].';
    c(2) = c(2)-0.5*t1(1);
    c(n) = c(n)-0.5*t(n);
    ev   = fft(c);
elseif pchoice == 5   % De la Vallee Poussin kernel
    c          = zeros(1,n);
    c(1)       = t(1);
    m          = floor(n/2);
    c(2:m+1)   = (1:m).*conj(t(2*m:-1:m+1))/m+t(2:m+1);
    c(m+2:2*m) = (m-1:-1:1).*t(m+2:2*m)/m+conj(t(m:-1:2));
    ev = fft(c)';
elseif pchoice == 6   % von Hann kernel
    tp   = pi/(2*n);
    coef = (cos(tp:tp:(n-1)*tp)).^2;
    c    = [t(1) coef.*t(2:n)+(1-coef).*t1];
    ev   = fft(c)';
elseif pchoice == 7   % Hamming kernel
    tp   = pi/(2*n);
    coef = (cos(tp:tp:(n-1)*tp)).^2;
    c    = [t(1) 0.46*(coef.*t(2:n)+(1-coef).*t1)+0.54*(t(2:n)+t1)];
    ev   = fft(c)';
elseif pchoice == 8   % Bernstein kernel
    tp   = pi/n;
    coef = 0.5*(1+exp((tp:tp:(n-1)*tp)*i));
    c    = [t(1) coef.*t(2:n)+(1-coef).*t1];
    ev   = fft(c)';
elseif pchoice == 9   % Generalized Jackson kernel: r = 2
    coef = jackson_dct(n,2); % coef also can be computed by 
    % coef = jackson_fft(n,2);  % or
    % coef = convol(n,2);
    c    = [t(1)*coef(1) coef(2:n).*t(2:n)+coef(n:-1:2).*t1];
    ev   = fft(c)';
elseif pchoice == 10  % Generalized Jackson kernel: r = 3
    coef = jackson_dct(n,3); % coef also can be computed by 
    % coef = jackson_fft(n,3);  % or
    % coef = convol(n,3);
    c    = [t(1)*coef(1) coef(2:n).*t(2:n)+coef(n:-1:2).*t1];
    ev   = fft(c)';
elseif pchoice == 11  % Generalized Jackson kernel: r = 4
    coef = jackson_dct(n,4); % coef also can be computed by 
    % coef = jackson_fft(n,4);  % or
    % coef = convol(n,4);
    c    = [t(1)*coef(1) coef(2:n).*t(2:n)+coef(n:-1:2).*t1];
    ev   = fft(c)';
elseif pchoice == 12  % Superoptimal preconditioner
    h    = zeros(n,1);   % h: first column of the circulant part
    s    = zeros(n,1);   % s: first column of the skew-circulant part
    h(1) = 0.5*t(1);
    s(1) = h(1);
    t    = t.';
    t1   = t1.';

    h(2:n) = 0.5*(t(2:n) + t1);
    s(2:n) = t(2:n)-h(2:n);

    ev1  = fft(h);
    coef = (1:-2/n:2/n-1)';
    c    = coef.*s;
    % first column of T. Chan's preconditioner
    % for the skew-circulant part
    ev2  =fft(c);

    d   = (exp((0:1/n:1-1/n)*pi*i)).';
    s   = s.*d;
    sev = fft(s);   % eigenvalues of the skew-circulant part
    sev = sev.*conj(sev);
    s   = ifft(s);
    s   = conj(d).*s;
    h   = coef.*s;
    ev3 = fft(h);

    ev = (abs(ev1).^2 + 2*ev1.*ev2+ev3)./ev1;
elseif pchoice == 0
    ev = ones(n,1);
end
ev = real(ev);
