function shepard_interp_nd_test01 ( prob, p, m, nd )

%*****************************************************************************80
%
%% shepard_interp_nd_test01() tests shepard_interp_nd() on an irregular grid.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 March 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer PROB, the problem number.
%
%    real P, the power used in the distance weighting.
%
%    integer M, the spatial dimension.
%
%    integer ND, the number of data points.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'shepard_interp_nd_test01():\n' );
  fprintf ( 1, '  Interpolate data from test_interp_nd() problem #%d\n', prob );
  fprintf ( 1, '  using Shepard interpolation with P = %g\n', p );
  fprintf ( 1, '  spatial dimension M = %d\n', m );
  fprintf ( 1, '  and an irregular grid of ND = %d data points.\n', nd );
%
%  Set problem parameters:
%
  c = rand ( m, 1 );
  w = rand ( m, 1 );
  xd = rand ( m, nd );
 
  zd = p00_f ( prob, m, c, w, nd, xd );
%
%  #1:  Does interpolant match function at interpolation points?
%
  ni = nd;
  xi = xd;
  zi = shepard_interp_nd ( m, nd, xd, zd, p, ni, xi );

  int_error = norm ( zi - zd ) / ni;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  L2 interpolation error averaged per interpolant node = %g\n', int_error );
%
%  #2: Approximation test.  Estimate the integral (f-interp(f))^2.
%
  ni = 100;
  xi = rand ( m, ni );
  zi = shepard_interp_nd ( m, nd, xd, zd, p, ni, xi );
  ze = p00_f ( prob, m, c, w, ni, xi );

  app_error = norm ( zi - ze ) / ni;

  fprintf ( 1, '  L2 approximation error averaged per 100 samples = %g\n', app_error );

  return
end
