function r = van_der_corput ( )

%*****************************************************************************80
%
%% van_der_corput() computes an element of a van der Corput sequence.
%
%  Discussion:
%
%    The global variables van_der_corput_key and van_der_corput_BASE
%    control the computation.  Therefore, before using this routine the
%    first time, the user should ensure that these values have been
%    set, perhaps by calls to van_der_corput_base_set() and
%    van_der_corput_key_set().  Each call by the user produces the next
%    element of the current sequence.  The key value is automatically
%    incremented.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 December 20080
%
%  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.
%
%  Output:
%
%    Output, real R, the key-th element 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 ( key, base );

  key = key + 1;

  van_der_corput_key_set ( key );

  return
end
