function r = van_der_corput_sequence ( n )

%*****************************************************************************80
%
%% van_der_corput_sequence() computes N elements of a van der Corput sequence.
%
%  Discussion:
%
%    The computation is controlled by the values of the internal base
%    and key, which the user must be certain have been initialized.
%    The current internal base and key are used, and the key is
%    incremented by N on return.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 December 2008
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Johannes van der Corput,
%    Verteilungsfunktionen I and II,
%    Nederl. Akad. Wetensch. Proc.,
%    Volume 38, 1935, pages 813-820, pages 1058-1066.
%
%  Input:
%
%    integer N, the number of elements to compute.
%
%  Output:
%
%    Output, real R(N), the key through key + N - 1 elements of
%    the van der Corput sequence for base BASE.
%
%  Local:
%
%    integer key, the key or index of the
%    desired element.  key should be nonnegative.  Only the integer
%    part of key is used.  key = 0 is allowed, and returns R = 0.
%
%    integer BASE, the van der Corput base,
%    which is typically a prime number.  Only the integer part of
%    BASE is used.  BASE must be greater than 1.
%
  base = van_der_corput_base_get ( );

  key = van_der_corput_key_get ( );

  r = i4_to_van_der_corput_sequence ( key, base, n );

  key = key + n;

  van_der_corput_key_set ( key );

  return
end
