function log_norm_test ( )

%*****************************************************************************80
%
%% log_norm_test tests log_norm.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 February 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../log_norm' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'log_norm_test\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test log_norm()\n' );
  fprintf ( 1, '\n' );

  for k = 1 : 5
    A = test_matrix ( k );
    Ap1 = norm ( A, 1 ); 
    Ap2 = norm ( A, 2 );
    Apoo = norm ( A, Inf );
    Al1 = log_norm ( A, 1 );
    Al2 = log_norm ( A, 2 );
    Aloo = log_norm ( A, Inf );
    fprintf ( 1, '  Test matrix:\n' );
    disp ( A )
    fprintf ( 1, '  p norms    %8.4f  %8.4f  %8.4f\n', Ap1, Ap2, Apoo );
    fprintf ( 1, '  log norms: %8.4f  %8.4f  %8.4f\n', Al1, Al2, Aloo );
    lambda = eig ( A );
    fprintf ( 1, '  eigenvalues:\n' );
    disp ( lambda );
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'log_norm_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../log_norm' );

  return
end
function A = test_matrix ( k )

%*****************************************************************************80
%
%% test_matrix returns a test matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 February 2021
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Guang-Da Hu, Mingzhu Liu,
%    The weighted logarithmic matrix norm and bounds for the matrix exponential,
%    Linear Algebra and Its Applications,
%    Volume 390, pages 145-154, 2004.
%
%    Guang-Da Hu, Taketomo Mitsui,
%    Bounds of the matrix eigenvalues and its exponential by Lyapunov equation,
%    Kybernetika,
%    Volume 48, pages 865-874, 2012.
%
%  Input:
%
%    integer K, the index of the matrix.
%    1 <= K <= 5.
%
%  Output:
%
%    real/complex A(N,N), the matrix.
%
  if ( k == 1 )
    A = [ ...
      -0.8,  0.4,  0.2;
       1.0, -3.0,  2.0;
       0.0,  1.0, -1.0 ];
  elseif ( k == 2 )
    A = [ ...
      5.0,  6.0,  3.0;
     -2.0,  7.0,  4.0;
     13.0,  9.0, -1.0 ];
  elseif ( k == 3 )
    A = [ ...
      1.0,  2.0,  1.0;
     -2.0,  0.0,  3.0;
     -1.0, -3.0,  0.0 ];
  elseif ( k == 4 )
    A = [ ...
      4.0+7.0i,  -10.0-3.0i,   1.0+6.0i;
     -7.0+1.0i,    4.0+6.0i,  -2.0+3.0i;
     -5.0+2.0i,    4.0+11.0i, -3.0-6.0i ];
  elseif ( k == 5 )
    A = [ ...
     -2.0,  0.0,  0.0;
      0.0, -1.0,  0.0;
      0.0,  0.0, -0.5 ];
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 'test_matrix - Fatal error!\n' );
    fprintf ( 1, '  Illegal input value for k = %d\n', k );
    fprintf ( 1, '  Legal values are 1 <= k <= 5.\n' );
    error ( 'test_matrix - Fatal error!' );
  end

  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

