function sinc_test ( )

%*****************************************************************************80
%
%% sinc_test() tests sinc().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../sinc' );

  timestamp ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincu_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version: %s\n', version ( ) );
  fprintf ( 1, '  Test sinc().' );

  sincn_antideriv_test ( );
  sincn_deriv_test ( );
  sincn_deriv2_test ( );
  sincn_fun_test ( );

  sincu_antideriv_test ( );
  sincu_deriv_test ( );
  sincu_deriv2_test ( );
  sincu_fun_test ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sinc_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  timestamp ( );

  rmpath ( '../sinc' );

  return
end
function sincn_antideriv_test ( )

%*****************************************************************************80
%
%% sincn_antideriv_test() tests sincn_antideriv().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincn_antideriv_test():\n' );
  fprintf ( 1, '  sincn_antideriv() evaluates the antiderivative of sincn(x).\n' );

  a = -7.0;
  b = +7.0;
  x = linspace ( a, b, 101 );
  y = sincn_antideriv ( x );

  clf ( );

  hold ( 'on' );
    plot ( x, y, 'g-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = antideriv sincn(x)' );
  filename = 'sincn_antideriv.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincn_deriv_test ( )

%*****************************************************************************80
%
%% sincn_deriv_test() tests sincn_deriv().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincn_deriv_test():\n' );
  fprintf ( 1, '  sincn_deriv() evaluates the derivative of sincn(x).\n' );

  a = -7.0;
  b = +7.0;
  x = linspace ( a, b, 101 );
  y = sincn_deriv ( x );

  clf ( );
 
  hold ( 'on' );
    plot ( x, y, 'r-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincn''(x)' );
  filename = 'sincn_deriv.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincn_deriv2_test ( )

%*****************************************************************************80
%
%% sincn_deriv2_test() tests sincn_deriv2().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincn_deriv2_test():\n' );
  fprintf ( 1, '  sincn_deriv2() evaluates the second derivative of sincn(x).\n' );

  a = -7.0;
  b = +7.0;
  x = linspace ( a, b, 101 );
  y = sincn_deriv2 ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'r-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincn"(x)' );
  filename = 'sincn_deriv2.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincn_fun_test ( )

%*****************************************************************************80
%
%% sincn_fun_test() tests sincn_fun().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2026
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincn_fun_test():\n' );
  fprintf ( 1, '  sincn_fun() evaluates the normalized sinc() function.\n' );

  a = -7.0;
  b = +7.0;
  x = linspace ( a, b, 101 );
  y = sincn_fun ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'b-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincn(x)' );
  filename = 'sincn_fun.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincu_antideriv_test ( )

%*****************************************************************************80
%
%% sincu_antideriv_test() tests sincu_antideriv().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincu_antideriv_test():\n' );
  fprintf ( 1, '  sincu_antideriv() evaluates the antiderivative of sincu(x).\n' );

  a = -20.0;
  b = +20.0;
  x = linspace ( a, b, 101 );
  y = sincu_antideriv ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'g-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = antideriv sincu(x)' );
  filename = 'sincu_antideriv.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincu_deriv2_test ( )

%*****************************************************************************80
%
%% sincu_deriv2_test() tests sincu_deriv2().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincu_deriv2_test():\n' );
  fprintf ( 1, '  sincu_deriv2() evaluates the second derivative of sincu(x).\n' );

  a = -20.0;
  b = +20.0;
  x = linspace ( a, b, 101 );
  y = sincu_deriv2 ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'r-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincu"(x)' );
  filename = 'sincu_deriv2.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincu_deriv_test ( )

%*****************************************************************************80
%
%% sincu_deriv_test() tests sincu_deriv().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincu_deriv_test():\n' );
  fprintf ( 1, '  sincu_deriv() evaluates the derivative of sincu(x).\n' );

  a = -20.0;
  b = +20.0;
  x = linspace ( a, b, 101 );
  y = sincu_deriv ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'r-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );

  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincu''(x)' );
  filename = 'sincu_deriv.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function sincu_fun_test ( )

%*****************************************************************************80
%
%% sincu_fun_test() tests sincu_fun().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 March 2026
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'sincu_fun_test():\n' );
  fprintf ( 1, '  sincu_fun() evaluates the unnormalized sinc() function.\n' );

  a = -20.0;
  b = +20.0;
  x = linspace ( a, b, 101 );
  y = sincu_fun ( x );

  clf ( );
  hold ( 'on' );
    plot ( x, y, 'b-', 'linewidth', 2 );
    plot ( [a,b], [0,0], 'k-', 'linewidth', 2 );
    ymin = min ( y );
    ymax = max ( y );
    if ( ymin <= 0.0 && 0.0 <= ymax )
      plot ( [0, 0], [ymin,ymax], 'k-', 'linewidth', 2 );
    end
  hold ( 'off' );


  grid ( 'on' );
  xlabel ( '<--- X --->' );
  ylabel ( '<--- Y --->' );
  title ( 'y = sincu(x)' );
  filename = 'sincu_fun.png';
  print ( '-dpng', filename )
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

