function hankel_inverse_test ( )

%*****************************************************************************80
%
%% hankel_inverse_test() tests hankel_inverse().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 May 2020
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../hankel_inverse' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'hankel_inverse_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  hankel_inverse() computes the inverse of a Hankel matrix.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '     N      |A|      |C|      |I-AC|        |I-AB|\n' );
  fprintf ( 1, '\n' );

  for n = [ 5, 10, 20 ]
    x = randn ( 2 * n - 1, 1 );
    A = hankel_matrix ( n, x );
    B = hankel_inverse ( n, x );
    C = inv ( A );
    I = eye ( n );
    error_ab = norm ( B * A - I, 'fro' ) + norm ( A * B - I, 'fro' );
    error_ac = norm ( C * A - I, 'fro' ) + norm ( A * C - I, 'fro' );
    norma_frobenius = norm ( A, 'fro' );
    normc_frobenius = norm ( C, 'fro' );
    fprintf ( 1, '  %4d  %10.2g  %10.2g  %14g  %14g\n', ...
      n, norma_frobenius, normc_frobenius, error_ac, error_ab );
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'hankel_inverse_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../hankel_inverse' );

  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

