function dirichlet ( x, n ) !*****************************************************************************80 ! !! dirichlet() evaluates the Dirichlet kernel function. ! ! Discussion: ! ! The Dirichlet kernel function is also called the periodic sinc function. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 12 July 2025 ! ! Author: ! ! John Burkardt ! ! Input: ! ! real x: the argument of the function. ! ! integer n: the degree of the function. ! ! Output: ! ! real dirichlet: the value of the function. ! implicit none integer, parameter :: rk8 = kind ( 1.0D+00 ) real ( kind = rk8 ) dirichlet integer n real ( kind = rk8 ) x if ( sin ( 0.5D+00 * x ) == 0.0D+00 ) then dirichlet = 1.0D+00 else dirichlet = sin ( 0.5D+00 * n * x ) / n / sin ( 0.5D+00 * x ) end if return end