function F = kernel( D, r, s ) 
%---------------------------------------------------
% applies a radix-r Fourier "kernel" 
% to each column of an r x s array D. 
% Nov. 24, 1992. 
%---------------------------------------------------

DFT=zeros(r);
wr  = exp(-i*2*pi/r); 
for j=0:r-1
 for k=0:r-1
   DFT(j+1,k+1)= wr^(j*k);    %get radix-r DFT matrix 
 end
 jj=j+1;
end

F = D;      %init a work space 
for col=1:s, 
   F(:,col) = DFT*D(:,col);     % pipe col's thru kernel engine 
end;

fprintf('r = %7.2f, s = %7.2f\n', r, s);

for j=1:r,
  for k=1:r,
    fprintf('DFT [ %7.0f %7.0f] = %10.5f %10.5fi\n', j,k,...
          real(DFT(j,k)), imag(DFT(j,k)));
  end
end 
end;


