function [ nd, xd, zd ] = lagrange_interp_nd_set2 ( m, ind, ab, f )

%*****************************************************************************80
%
%% lagrange_interp_nd_set2() sets an M-dimensional Lagrange interpolant.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 September 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the spatial dimension.
%
%    integer IND(M), the index or level of the 1D rule to be used
%    in each dimension.
%
%    real AB(M,2), the upper and lower interval endpoints in 
%    each dimension.
%
%    function value = F ( m, nd, xd ), the M-file which will
%    evaluate the function of an M-dimensional argument, for ND
%    evaluation points stored in the array XD(M,ND), returning the
%    results in the vector VALUE(ND).
%
%  Output:
%
%    integer ND, the number of points in the product grid.
%
%    real XD(M,ND), the points at which data was sampled.
%
%    real ZD(ND), the function evaluated at the points XD.
%

%
%  Determine the number of data points.
%
    nd = 1;
    for i = 1 : m
      nd = nd * order_from_level_135 ( ind(i) );
    end
%
%  Compute the data points.
%
    xd = zeros ( m, nd );
    for i = 1 : m
      n_1d = order_from_level_135 ( ind(i) );
      x_1d(1:n_1d) = cc_compute_points ( n_1d );
      x_1d(1:n_1d) = 0.5 * ( ( 1.0 - x_1d(1:n_1d) ) * ab(i,1) ...
                           + ( 1.0 + x_1d(1:n_1d) ) * ab(i,2) );
      xd = r8vec_direct_product ( i, n_1d, x_1d, m, nd, xd );
    end
%
%  Compute the data values.
%
    zd = f ( m, nd, xd );

  return
end
