function circle_distance_test ( )

%*****************************************************************************80
%
%% circle_distance_test() tests circle_distance().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../circle_distance' );

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

  if ( is_octave ( ) )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'circle_distance_test:\n' );
    fprintf ( 1, '  This example will not run on Octave!' );
    fprintf ( 1, '  Abnormal end of execution.\n' );
    return
  end

  n = 10000;
  [ mu, var ] = circle_distance_stats ( n );
  mu_exact = 4.0 / pi;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using N = %d sample points,\n', n );
  fprintf ( 1, '  Estimated mean distance = %g\n', mu );
  fprintf ( 1, '  Exact mean distance     = %g\n', mu_exact );
  fprintf ( 1, '  Estimated variance      = %g\n', var );

  n = 10000;
  circle_distance_histogram ( n );
  filename = 'circle_distance_histogram.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  pause ( 5 );

  circle_distance_pdf ( );
  filename = 'circle_distance_pdf.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  pause ( 5 );

  clf
  hold on
  n = 10000;
  circle_distance_histogram ( n );
  circle_distance_pdf ( );
  hold off
  filename = 'circle_distance_compare.png';
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
  pause ( 5 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'circle_distance_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../circle_distance' );

  return
end
function value = is_octave ( )

%*****************************************************************************80
%
%% is_octave returns true if Octave has called this function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 December 2019
%
%  Author:
%
%    John Burkardt
%
%  Output:
%
%    logical VALUE: is true if Octave is calling.
%
  persistent cacheval;

  if ( isempty ( cacheval ) )
    cacheval = ( exist ( "OCTAVE_VERSION", "builtin" ) > 0 );
  end

  value = cacheval;

  return
end
function timestamp ( )

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

  return
end

