function gamma = pointset_spacing ( dim_num, n, z )

%*****************************************************************************80
%
%% pointset_spacing() determines the minimum spacing between points in the set.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 October 2004
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Max Gunzburger and John Burkardt,
%    Uniformity Measures for Point Samples in Hypercubes.
%
%  Input:
%
%    integer DIM_NUM, the spatial dimension.
%
%    integer N, the number of points.
%
%    real Z(N,DIM_NUM), the point distribution.
%
%  Output:
%
%    real GAMMA(N), the minimum distance between each point and a 
%    distinct point in the set.
%
  gamma(1:n) = Inf;

  for j1 = 1 : n

    for j2 = 1 : n

      if ( j2 ~= j1 )
        gamma(j1) = min ( gamma(j1), ...
          sum ( ( z(j1,1:dim_num) - z(j2,1:dim_num) ).^2 ) );
      end

    end

  end

  gamma(1:n) = sqrt ( gamma(1:n) );

  return
end
