function niederreiter2_test04 ( )

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

  fprintf ( 1, '\n' );
  fprintf ( 1, 'NIEDERREITER2_TEST04\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 call NIEDERREITER2 repeatedly.\n' );

  for dim_num = 2 : dim_max

    key = 0;

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

    for i = 0 : 110
      key_in = key;
      [ r, key ] = niederreiter2 ( dim_num, key );
      key_out = key;
      if ( i <= 11 || 95 <= i )
        fprintf ( 1, '%3d  %3d  ', key_in, key_out );
        for j = 1 : dim_num
          fprintf ( 1, '%10f', r(j) );
        end
        fprintf ( 1, '\n' );
      elseif ( i == 12 )
        fprintf ( 1, '......................\n' );
      end
    end

  end

  return
end
