function t = data_to_table ( x, y )

%*****************************************************************************80
%
%% data_to_table() computes a divided difference table from raw data.
%
%  Discussion:
%
%    The full triangular table is computed and returned.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Carl deBoor,
%    A Practical Guide to Splines,
%    Springer, 2001,
%    ISBN: 0387953663,
%    LC: QA1.A647.v27.
%
%  Input:
%
%    real x(n), y(n): the pairs of data.
%
%  Output:
%
%    real t(n,n): the full divided difference table.  
%    The usual divided difference vector is in the first row.
%
  n = length ( x );

  t = zeros(n,n);
%
%  Column 1 is the y data.
%
  t(1:n,1) = y(1:n);
%
%  Compute columns 2 through n.
%
  for j = 2 : n
    for i = 1 : n + 1 - j
      t(i,j) = ( t(i+1,j-1) - t(i,j-1) ) / ( x(i+j-1) - x(i) );
    end
  end

  return
end
