# include # include using namespace std; # include "dirichlet.hpp" //****************************************************************************80 double dirichlet ( double x, int n ) //****************************************************************************80 // // Purpose: // // 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: // // 13 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. // { double value; if ( sin ( 0.5 * x ) == 0.0 ) { value = 1.0; } else { value = sin ( 0.5 * n * x ) / n / sin ( 0.5 * x ); } return value; }