function lcrg_key_test ( )

%*****************************************************************************80
%
%% lcrg_key_test() tests lcrg_key().
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    05 April 2013
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'lcrg_key_test():\n' );
  fprintf ( 1, '  lcrg_key() directly computes the updated value of a\n' );
  fprintf ( 1, '  key used by an linear congruential random number\n' );
  fprintf ( 1, '  generator.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '       I          key          key          key    U\n' );
  fprintf ( 1, '                 Input        Output          LCRG\n' );
  fprintf ( 1, '\n' );
%
%  These parameters define the old (1969) IBM 360 random number generator:
%
  a = 16807;
  b = 0;
  c = 2147483647;
%
%  This key value was used in Pierre L'Ecuyer's article.
%
  key_start = 12345;

  key = key_start;
%
%  Compute 1000 random numbers "the hard way", that is, sequentially.
%  Every now and then, call LCRG_key to compute key directly.
%
  for i = 1 : 1000

    key_in = key;
    [ u, key ] = r8_uniform_01 ( key );
    key_out = key;

    if ( i <= 10 || i == 100 || i == 1000 )

      key_lcrg = lcrg_key ( a, b, c, i, key_start );

      fprintf ( 1, '  %6d  %12d  %12d  %12d  %14f\n', ...
        i, key_in, key_out, key_lcrg, u );

    end

  end

  return
end
