function value = dirichlet ( x, n )

%*****************************************************************************80
%
%% dirichlet() evaluates the Dirichlet kernel function.
%
%  Discussion:
%
%    The Dirichlet kernel function is also called the periodic sinc function.
%
%    The MATLAB signal toolbox provides the diric() function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 July 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real x: the argument of the function.
%
%    integer n: the degree of the function.
%
%  Output:
%
%    real value: the value of the function.
%
  value = ones ( size ( x ) );

  nz = find ( sin ( 0.5 * x ) ~= 0.0 );

  value(nz) = sin ( 0.5 * n * x(nz) ) ./ n ./ sin ( 0.5 * x(nz) );

  return
end

