function sobol_test05 ( )

%*****************************************************************************80
%
%% sobol_test05() tests i4_sobol().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 December 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'SOBOL_TEST05\n' );
  fprintf ( 1, '  I4_SOBOL computes the next element of a Sobol sequence.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  In this test, we demonstrate how the key can be\n' );
  fprintf ( 1, '  manipulated to skip ahead in the sequence, or\n' );
  fprintf ( 1, '  to come back to any part of the sequence.\n' );
  fprintf ( 1, '\n' );

  dim_num = 3;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Using dimension DIM_NUM =   %d\n', dim_num );

  key = 0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   I4_SOBOL\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );

  for i = 0 : 10
    [ r, key_out ] = i4_sobol ( dim_num, key );
    fprintf ( 1, '%6d %6d  ', key, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f  ', r(j) );
    end
    fprintf ( 1, '\n' );
    key = key_out;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Jump ahead by increasing key:\n' );
  fprintf ( 1, '\n' );

  key = 100;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   I4_SOBOL\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 5
    [ r, key_out ] = i4_sobol ( dim_num, key );
    fprintf ( 1, '%6d %6d  ', key, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f  ', r(j) );
    end
    fprintf ( 1, '\n' );
    key = key_out;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Jump back by decreasing key:\n' );
  fprintf ( 1, '\n' );

  key = 3;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   I4_SOBOL\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );

  for i = 0 : 10
    [ r, key_out ] = i4_sobol ( dim_num, key );
    fprintf ( 1, '%6d %6d  ', key, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f  ', r(j) );
    end
    fprintf ( 1, '\n' );
    key = key_out;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Jump back by decreasing key:\n' );
  fprintf ( 1, '\n' );

  key = 98;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   I4_SOBOL\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 5
    [ r, key_out ] = i4_sobol ( dim_num, key );
    fprintf ( 1, '%6d %6d  ', key, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f  ', r(j) );
    end
    fprintf ( 1, '\n' );
    key = key_out;
  end

  return
end
