function closest_point_brute_test ( )

%*****************************************************************************80
%
%% closest_point_brute_test() tests closest_point_brute().
%
%  Discussion:
%
%    We are given R, a set of NR points in M dimensions.
%
%    We are given S, a points in M dimensions.
%
%    We seek the index J of the point R(J)
%    which is nearest to S over all points in R.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 August 2024
%
%  Author:
%
%    John Burkardt
%
%  Local:
%
%    integer M, the spatial dimension.
%
%    integer NR, the number of data points.
%
%    real R(M,NR), the data points.
%
%    real S(M), the sample point. 
%
  addpath ( '../closest_point_brute' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'closest_point_brute_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version );
  fprintf ( 1, '  Test closest_point_brute().\n' );

  m = 2;
  fprintf ( 1, '  Spatial dimension m = %d\n', m );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Timing closest_point_brute():\n' );
  nr = 1;

  while ( nr <= 65536 )

    r = rand ( nr, m );
    s = rand ( 1, m );
 
    tic ( );
    [ near_index, near_dist ] = closest_point_brute ( m, nr, r, s );
    dt = toc ( );

    fprintf ( 1, '%5d  %5d  %8.2g  %8.2g\n', nr, near_index, near_dist, dt );

    nr = nr * 2;

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Timing closest_point_brute2():\n' );
  nr = 1;

  while ( nr <= 65536 )

    r = rand ( nr, m );
    s = rand ( 1, m );
 
    tic ( );
    [ near_index, near_dist ] = closest_point_brute2 ( m, nr, r, s );
    dt = toc ( );

    fprintf ( 1, '%5d  %5d  %8.2g  %8.2g\n', nr, near_index, near_dist, dt );

    nr = nr * 2;

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Timing closest_point_brute3():\n' );
  nr = 1;

  while ( nr <= 65536 )

    r = rand ( nr, m );
    s = rand ( 1, m );
 
    tic ( );
    [ near_index, near_dist ] = closest_point_brute3 ( m, nr, r, s );
    dt = toc ( );

    fprintf ( 1, '%5d  %5d  %8.2g  %8.2g\n', nr, near_index, near_dist, dt );

    nr = nr * 2;

  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'closest_point_brute_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../closest_point_brute' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end
