function trig_interp_cardinal_test ( label, f, xmin, xmax )

%*****************************************************************************80
%
%% trig_interp_cardinal_test() tests trig_interp_cardinal().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string label, a label for the function.
%
%    function handle f, a function handle for the function.
%
%    real xmin, xmax, the range of the interpolation.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'trig_interp_cardinal_test:\n' );
  fprintf ( 1, '  Problem: %s\n', label );

  for log2n = 1 : 6

    nd = 2 ^ log2n;

    xd = linspace ( xmin, xmax, nd );
    yd = f ( xd );

    ni = 101;
    xi = linspace ( xmin, xmax, ni );
    yi = trig_interp_cardinal ( xd, yd, xi );

    ye = f ( xi );

    plot ( xd, yd, 'k.', ...
           xi, yi, 'b-', ...
           xi, ye, 'r-', 'Markersize', 35, 'Linewidth', 3 );

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

  end

  return
end

