function niederreiter2_test05 ( )

%*****************************************************************************80
%
%% niederreiter2_test05() tests niederreiter2().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    17 November 2008
%
%  Author:
%
%    John Burkardt
%
  dim_num = 3;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'niederreiter2_test05():\n' );
  fprintf ( 1, '  niederreiter2() computes the next element of\n' );
  fprintf ( 1, '  a Niederreiter quasirandom sequence using base 2.\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' );
  fprintf ( 1, '  Using dimension DIM_NUM =   %d\n', dim_num );

  key = 0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   Niederreiter2\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );
  for i = 0 : 10
    key_in = key;
    [ r, key ] = niederreiter2 ( dim_num, key );
    key_out = key;
    fprintf ( 1, '%3d  %3d  ', key_in, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f', r(j) );
    end
    fprintf ( 1, '\n' );
  end

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

  key = 100;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   Niederreiter2\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 5
    key_in = key;
    [ r, key ] = niederreiter2 ( dim_num, key );
    key_out = key;
    fprintf ( 1, '%3d  %3d  ', key_in, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f', r(j) );
    end
    fprintf ( 1, '\n' );
  end

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

  key = 3;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   Niederreiter2\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );
  for i = 0 : 10
    key_in = key;
    [ r, key ] = niederreiter2 ( dim_num, key );
    key_out = key;
    fprintf ( 1, '%3d  %3d  ', key_in, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f', r(j) );
    end
    fprintf ( 1, '\n' );
  end

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

  fprintf ( 1, '\n' );
  fprintf ( 1, '  key  key   Niederreiter2\n' );
  fprintf ( 1, '  In    Out\n' );
  fprintf ( 1, '\n' );
  for i = 1 : 5
    key_in = key;
    [ r, key ] = niederreiter2 ( dim_num, key );
    key_out = key;
    fprintf ( 1, '%3d  %3d  ', key_in, key_out );
    for j = 1 : dim_num
      fprintf ( 1, '%10f', r(j) );
    end
    fprintf ( 1, '\n' );
  end

  return
end
