RngStream
Date: 2013-11-17

org.simgrid.msg

## Class RngStream

- java.lang.Object
- - org.simgrid.msg.RngStream

-     public class RngStream
      extends java.lang.Object

  Export of RngStreams for Java

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RngStream()` Creates and returns a new stream without identifier.
    `RngStream(java.lang.String name)` Creates and returns a new stream with identifier "name".

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `advanceState(int e, int g)` Advances the state of the stream by k values, without modifying the states of other streams (as in RngStream_SetSeed), nor the values of Bg and Ig associated with this stream.
    `protected void` | `finalize()` Destructor
    `static void` | `nativeInit()` Class initializer, to initialize various JNI stuff
    `int` | `randInt(int i, int j)` Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, . . . , j}
    `double` | `randU01()` Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), after advancing the state by one step.
    `void` | `resetNextSubstream()` Reinitializes the stream g to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng .
    `void` | `resetStart()` Reinitializes the stream g to its initial state: Cg and Bg are set to Ig .
    `void` | `restartStartSubstream()` Reinitializes the stream g to the beginning of its current substream: Cg is set to Bg .
    `void` | `setAntithetic(boolean a)` If a = true the stream g will start generating antithetic variates, i.e., 1 - U instead of U , until this method is called again with a = false.
    `static boolean` | `setPackageSeed(int[] seed)` Sets the initial seed of the package RngStreams to the six integers in the vector seed.
    `boolean` | `setSeed(int[] seed)` Sets the initial seed Ig of stream g to the vector seed.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RngStream

          public RngStream()

      Creates and returns a new stream without identifier. This procedure reserves space to keep the information relative to the RngStream, initializes its seed Ig , sets Bg and Cg equal to Ig , sets its antithetic and precision switches to 0. The seed Ig is equal to the initial seed of the package given by setPackageSeed if this is the first stream created, otherwise it is Z steps ahead of that of the most recently created stream.

    - #### RngStream

          public RngStream(java.lang.String name)

      Creates and returns a new stream with identifier "name". This procedure reserves space to keep the information relative to the RngStream, initializes its seed Ig , sets Bg and Cg equal to Ig , sets its antithetic and precision switches to 0. The seed Ig is equal to the initial seed of the package given by setPackageSeed if this is the first stream created, otherwise it is Z steps ahead of that of the most recently created stream.

  - ### Method Detail

    - #### finalize

          protected void finalize()

      Destructor
      Overrides:
        `finalize` in class `java.lang.Object`

    - #### setPackageSeed

          public static boolean setPackageSeed(int[] seed)

      Sets the initial seed of the package RngStreams to the six integers in the vector seed. This will be the seed (initial state) of the first stream. If this procedure is not called, the default initial seed is (12345, 12345, 12345, 12345, 12345, 12345). If it is called, the first 3 values of the seed must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less than m2 = 4294944443, and not all 0. Returns false for invalid seeds, and true otherwise.

    - #### resetStart

          public void resetStart()

      Reinitializes the stream g to its initial state: Cg and Bg are set to Ig .

    - #### restartStartSubstream

          public void restartStartSubstream()

      Reinitializes the stream g to the beginning of its current substream: Cg is set to Bg .

    - #### resetNextSubstream

          public void resetNextSubstream()

      Reinitializes the stream g to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng .

    - #### setAntithetic

          public void setAntithetic(boolean a)

      If a = true the stream g will start generating antithetic variates, i.e., 1 - U instead of U , until this method is called again with a = false.

    - #### setSeed

          public boolean setSeed(int[] seed)

      Sets the initial seed Ig of stream g to the vector seed. This vector must satisfy the same conditions as in setPackageSeed. The stream is then reset to this initial seed. The states and seeds of the other streams are not modified. As a result, after calling this procedure, the initial seeds of the streams are no longer spaced Z values apart. We discourage the use of this procedure. Returns false for invalid seeds, and true otherwise.

    - #### advanceState

          public void advanceState(int e,
                          int g)

      Advances the state of the stream by k values, without modifying the states of other streams (as in RngStream_SetSeed), nor the values of Bg and Ig associated with this stream. If e > 0, then k = 2e + c; if e < 0, then k = -2-e + c; and if e = 0, then k = c. Note: c is allowed to take negative values. We discourage the use of this procedure.

    - #### randU01

          public double randU01()

      Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), after advancing the state by one step. The returned number has 32 bits of precision in the sense that it is always a multiple of 1/(232 - 208), unless RngStream_IncreasedPrecis has been called for this stream.

    - #### randInt

          public int randInt(int i,
                    int j)

      Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, . . . , j}

    - #### nativeInit

          public static void nativeInit()

      Class initializer, to initialize various JNI stuff