function yi = trig_interp_cardinal ( xd, yd, xi )

%*****************************************************************************80
%
%% trig_interp_cardinal() evaluates a trigonometric cardinal interpolant.
%
%  Discussion:
%
%    Given n values of x with equal spacing h, we seek a function y
%    which is periodic over x(1) to x(n+1) = x(n) + h, such that
%      y(x(i)) = y(i)
%    for a given set of n data values.
%
%    This function evaluates the trigonometric cardinal interpolant function
%    for this data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    https://en.wikipedia.org/wiki/Trigonometric_interpolation
%
%  Input:
%
%    real XD(ND), equispaced data nodes.
%
%    real YD(ND), data values at the data nodes.
%
%    real XI(NI), interpolation points.
%
%  Output:
%
%    real YI(NI), interpolation values.
%
  nd = length ( xd );
%
%  Compute the spacing of the given independent variable.
%
  h = xd(2) - xd(1);
%
%  Evaluate the interpolant.
%
  yi = zeros ( size ( xi ) );
  for j = 1 : nd
    yi = yi + yd(j) * trig_cardinal ( xi, xd(j), nd, h );
  end

  return
end

