function trig_cardinal_test ( nd )

%*****************************************************************************80
%
%% trig_cardinal_test() tests trig_cardinal().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer nd, the number of data points.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'trig_cardinal_test():\n' );
  fprintf ( 1, '  Test trig_cardinal()\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Generate and plot a set of cardinal trigonometric functions.\n' );

  xmin = 0.0;
  xmax = 2.0 * pi;
  ni = 101;
  xi = linspace ( xmin, xmax, ni );

  xd = linspace ( xmin, xmax, nd + 1 );
  xd = xd(1:nd);
  h = xd(2) - xd(1);

  clf ( );
  hold ( 'on' );

  for j = 1 : nd
    yi = trig_cardinal ( xi, xd(j), nd, h );
    plot ( xi, yi, 'Linewidth', 3 );
  end

  grid ( 'on' );
  xlabel ( '<-- X -->' );
  ylabel ( '<-- Y(X) -->' );
  label = sprintf ( 'Cardinal trigonometric family of size %d.', nd );
  title ( label );
  hold ( 'off' );

  filename = sprintf ( 'trig_cardinal_%d.png', nd );
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  pause ( 5 );

  return
end

