function cgs2_test ( )

%*****************************************************************************80
%
%% cgs2_test() tests cgs2().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 January 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'cgs2_test():\n' );
  fprintf ( 1, '  Test cgs2().\n' );
%
%  Use columns of the same matrix for all tests.
%
  key = 123456789;
  rng ( key );
  A = round ( 20.0 * rand ( 3, 4 ) - 10.0 );

  m = 3;
  na = 2;
  A1 = A(1:m,1:na);
  r8mat_print ( m, na, A1, '  A1:' );
  U = cgs2 ( A1 );
  [ m, nu ] = size ( U );
  r8mat_print ( m, nu, U, '  U1:' );
  UTU = U' * U;
  r8mat_print ( nu, nu, UTU, '  Check:' );

  m = 3;
  na = 3;
  A2 = A(1:m,1:na);
  r8mat_print ( m, na, A2, '  A2:' );
  U = cgs2 ( A2 );
  [ m, nu ] = size ( U );
  r8mat_print ( m, nu, U, '  U:' );
  UTU = U' * U;
  r8mat_print ( nu, nu, UTU, '  Check:' );

  m = 3;
  na = 4;
  A3 = A(1:m,1:na);
  r8mat_print ( m, na, A3, '  A3:' );
  U = cgs2 ( A3 );
  [ m, nu ] = size ( U );
  r8mat_print ( m, nu, U, '  U:' );
  UTU = U' * U;
  r8mat_print ( nu, nu, UTU, '  Check:' );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'cgs2_test\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
