function mgs_test ( )

%*****************************************************************************80
%
%% mgs_test tests mgs.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../mgs' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mgs_test\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test mgs\n' );

  m = 200;
  n = 50;
  A = rand ( m, n );
  [ R, Q ] = mgs ( A );
  A2 = Q * R;
  diff = norm ( A - A2, 'fro' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  A is a random %d by %d matrix.\n', m, n );
  fprintf ( 1, '  mgs computes factors Q and R.\n' );
  fprintf ( 1, '  Q is an %d by %d orthogonal matrix.\n', m, m );
  fprintf ( 1, '  R is an %d by %d upper triangular matrix.\n', m, n );
  fprintf ( 1, '  Frobenius norm of A - Q * R = %g\n', diff );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mgs_test\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../mgs' );

  return
end
