Up: Skip Ahead


DRANDSKIPAHEAD / SRANDSKIPAHEAD

Advance a generator N places.

(Note that SRANDSKIPAHEAD is the single precision version of DRANDSKIPAHEAD. The argument lists of both routines are identical except that any double precision arguments of DRANDSKIPAHEAD are replaced in SRANDSKIPAHEAD by single precision arguments - type REAL in FORTRAN or type float in C).

— SUBROUTINE: DRANDSKIPAHEAD (N,STATE,INFO)
— Input: INTEGER N

On input: number of places to skip ahead.
Constraint: N>=0.

— Input/Output: INTEGER STATE(*)

The STATE vector holds information on the state of the base generator being used and as such its minimum length varies. Prior to calling DRANDSKIPAHEAD STATE must have been initialized. See Initialization of the Base Generators for information on initialization of the STATE variable.
On input: the current state of the base generator.


On output: The STATE vector for a generator that has been advanced N places.
Constraint: The STATE vector must be for either the NAG basic, Wichmann-Hill or L'Ecuyer Combined Recursive base generators.

— Output: INTEGER INFO

On output: INFO is an error indicator. On successful exit, INFO contains 0. If INFO = -i on exit, the i-th argument had an illegal value.

     Example:
     

          C     Generate 3 * 100 values from the Uniform distribution
          C     Multiple streams generated using the Skip Ahead method
                INTEGER LSTATE,N
                PARAMETER (LSTATE=16,N=100)
                INTEGER I,INFO,NSKIP
                INTEGER SEED(1),STATE1(LSTATE),STATE2(LSTATE),STATE3(LSTATE)
                INTEGER X1(N),X2(N),X3(N)
                DOUBLE PRECISION A,B
          
          C     Set the seed
                SEED(1) = 1234
          
          C     Set the distributional parameters
                A = 0.0D0
                B = 1.0D0
          
          C     Initialize the STATE1 vector
                CALL DRANDINITIALIZE(1,1,SEED,1,STATE1,LSTATE,INFO)
          
          C     Copy the STATE1 vector into other state vectors
                DO 20 I = 1,LSTATE
                  STATE2(I) = STATE1(I)
                  STATE3(I) = STATE1(I)
          20    CONTINUE
          
          C     Calculate how many places we want to skip, this
          C     should be >> than the number of variates we
          C     wish to generate from each stream
                NSKIP = N * N
          
          C     Advance each stream, first does not need changing
                CALL DRANDSKIPAHEAD(NSKIP,STATE2,INFO)
                CALL DRANDSKIPAHEAD(2*NSKIP,STATE3,INFO)
          
          C     Generate 3 sets of N variates from the Univariate distribution
                CALL DRANDUNIFORM(N,A,B,STATE1,X1,LDX,INFO)
                CALL DRANDUNIFORM(N,A,B,STATE2,X2,LDX,INFO)
                CALL DRANDUNIFORM(N,A,B,STATE3,X3,LDX,INFO)
          
          C     Print the results
                DO 40 I = 1,N
                  WRITE(6,*) X1(I),X2(I),X3(I)
          40    CONTINUE