function tennis_matrix_test ( )

%*****************************************************************************80
%
%% tennis_matrix_test() tests tennis_matrix().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 December 2022
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../tennis_matrix' );

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

  tennis_matrix_spy_test ( );
  tennis_matrix_eigen_test ( );
  tennis_labels_test ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'tennis_matrix_test()\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../tennis_matrix' );

  return
end
function tennis_labels_test ( )

%*****************************************************************************80
%
%% tennis_labels_test() tests tennis_labels().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 December 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'tennis_labels_test():\n' );
  fprintf ( 1, '  tennis_labels() provides labels for the tennis states.\n' );
  fprintf ( 1, '\n' );

  labels = tennis_labels ( );
  for i = 1 : length ( labels )
    fprintf ( 1, '  %2d: %s\n', i, labels{i} );
  end

  return
end
function tennis_matrix_eigen_test ( )

%*****************************************************************************80
%
%% tennis_matrix_eigen_test() does an eigenanalysis of a tennis matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 December 2022
%
%  Author:
%
%    John Burkardt
%
  p = 0.60;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'tennis_matrix_eigen_test():\n' );
  fprintf ( 1, '  tennis_matrix() is evaluated with probability\n' );
  fprintf ( 1, '  of server winning a single serve p = %g\n', p );
  fprintf ( 1, '  eigen() computes eigenvalues and eigenvectors.\n' );

  A = tennis_matrix ( p );
  [ V, D ] = eig ( A );
  
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Eigenvalues:\n' );
  disp ( diag ( D ) );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Eigenvectors:\n' );
  disp ( V );

  return
end
function tennis_matrix_spy_test ( )

%*****************************************************************************80
%
%% tennis_matrix_spy_test() uses spy() to display a tennis matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 December 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'tennis_matrix_spy_test():\n' );
  fprintf ( 1, '  tennis_matrix() is evaluated for p=0.5.\n' );
  fprintf ( 1, '  spy() displays the nonzero elements of the resulting matrix.\n' );

  p = 0.5;
  A = tennis_matrix ( p );
  spy ( A );
  filename = 'tennis_matrix.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  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

