function yi = trig_interp_lagrange ( xd, yd, xi )

%*****************************************************************************80
%
%% trig_interp_lagrange() evaluates a trigonometric Lagrange interpolant.
%
%  Discussion:
%
%    Given n values of x, we seek a function y
%    which is periodic over x(1) to x(n)
%      y(x(i)) = y(i)
%    for a given set of n data values.
%
%    This function evaluates the trigonometric Lagrange interpolant function
%    for this data.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 August 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Anthony Austin, Lloyd Trefethen,
%    Trigonometric interpolation and quadrature at perturbed points,
%    SIAM Journal on Numerical Analysis,
%    Volume 55, Number 5, pages 2113-2122, 2017.
%
%  Input:
%
%    real XD(ND), the data nodes, which need not be equally spaced.
%    Note that ND should be odd.
%
%    real YD(ND), data values at the data nodes.
%
%    real XI(NI), interpolation points.
%
%  Output:
%
%    real YI(NI), interpolation values.
%
  nd = length ( xd );

  yi = zeros ( size ( xi ) );
  for j = 1 : nd
    yi = yi + yd(j) * trig_lagrange ( xi, xd, j );
  end

  return
end

