function hankel_cholesky_upper_test ( )

%*****************************************************************************80
%
%% hankel_cholesky_upper_test() tests hankel_cholesky_upper().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 January 2017
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'hankel_cholesky_upper_test():\n' );
  fprintf ( 1, '  HANKEL_CHOLESKY_UPPER is given a Hankel matrix H and \n' );
  fprintf ( 1, '  computes an upper triangular matrix R such that \n' );
  fprintf ( 1, '  H = R'' * R\n' );
%
%  Get a Hankel matrix that is positive definite.
%
  n = 5;
  lii = rand ( n, 1 );
  liim1 = rand ( n - 1, 1 );
  l = hankel_spd_cholesky_lower ( n, lii, liim1 );
  h = l * l';
  r8mat_print ( n, n, h, '  The Hankel matrix H:' );
%
%  Compute R using MATLAB.
%
  [ r1, flag ] = chol ( h, 'upper' );
  if ( flag ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, ' CHOL says H is not positive definite.\n' );
  else
    r8mat_print ( n, n, r1, '  R computed by CHOL:' );
  end
%
%  Compute R using R8MAT_CHOLESKY_FACTOR_UPPER.
%
  [ r2, flag ] = r8mat_cholesky_factor_upper ( n, h );
  if ( flag ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, ' R8MAT_CHOLESKY_FACTOR_UPPER says H is not positive definite.\n' );
  else
    r8mat_print ( n, n, r2, '  R computed by R8MAT_CHOLESKY_FACTOR_UPPER:' );
  end
%
%  Compute R using HANKEL_CHOLESKY.
%
  hanti = zeros ( 2 * n - 1, 1 );
  hanti(1:n,1) = h(1:n,1);
  hanti(n+1:2*n-1,1) = h(n,2:n)';

  r3 = hankel_cholesky_upper ( n, hanti );
  r8mat_print ( n, n, r3, '  R computed by HANKEL_CHOLESKY:' );

  return
end
