RNStreamProvider

class RNStreamProvider(defaultStreamNum: Int = 1) : RNStreamProviderIfc

A concrete implementation of RNStreamProviderIfc. If more than streamNumberWarningLimit streams are made a warning message is logged. Generally, unless you know what you are doing you should not need an immense number of streams. Instead, use a small number of streams many times. Conceptually this provider could have a possibly infinite number of streams, which would have bad memory implications. Thus, the reason for the warning. The default stream if not set is the first stream.

Constructors

Link copied to clipboard
constructor(defaultStreamNum: Int = 1)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val defaultStreamNumber: Int

The sequence number associated with the default random number stream. This allows clients to know what stream number has been assigned to the default.

Link copied to clipboard
open override var streamNumberWarningLimit: Int

When the number of streams provided reaches this limit a warning is issued. This warning may indicate that a conceptual misunderstanding is occurring that is causing a large number of streams to be used. Generally, a small number of streams should be used, with each stream being accessed many times.

Functions

Link copied to clipboard

Causes all streams that have been provided to advance to the start of their next sub-stream. Thus, the individual streams skip any pseudo-random numbers in their current sub-stream and are positioned at the beginning of their next sub-stream. Note: This call only effects previously provided streams.

Link copied to clipboard
open override fun advanceStreamMechanism(n: Int)

Advances the state of the provider through n streams. Acts as if n streams were created, without actually creating the streams. lastRNStreamNumber() remains the same after calling this method. In other words, this method should act as if nextRNStream() was not called but advance the underlying stream mechanism as if n streams had been provided.

Link copied to clipboard

Returns the current seed

Link copied to clipboard

Gets the default initial seed: seed = {12345, 12345, 12345, 12345, 12345, 12345};

Link copied to clipboard

It is useful to designate one of the streams in the sequence of streams as the default stream from the provider. When clients don't care to get new streams, this method guarantees that the same stream is returned every time.

Link copied to clipboard
open fun hasProvided(stream: RNStreamIfc): Boolean
Link copied to clipboard
fun initialSeed(seed: LongArray = longArrayOf(12345, 12345, 12345, 12345, 12345, 12345))

Sets the initial seed to the six integers in the vector seed0..5. This will be the seed (initial state) of the first stream. By default, this seed is (12345, 12345, 12345, 12345, 12345, 12345).

Link copied to clipboard
open override fun lastRNStreamNumber(): Int

Each call to nextStream() makes another stream in the sequence of streams. This method should return the number of streams provided by the provider. If nextStream() is called once, then lastRNStreamNumber() should return 1. If nextStream() is called twice then lastRNStreamNumber() should return 2, etc. Thus, this method returns the number in the sequence associated with the last stream made. If lastRNStreamNumber() returns 0, then no streams have been provided.

Link copied to clipboard
open override fun nextRNStream(): RNStreamIfc

Tells the provider to make and return the next RNStreamIfc in the sequence of streams

Link copied to clipboard

Causes all streams that have been provided to be reset to the start of their stream. Thus, the individual streams act as if they have not generated any pseudo-random numbers. Note: This call only effects previously provided streams.

Link copied to clipboard

Causes all streams that have been provided to be reset to the start of their current sub-stream. Thus, the individual streams act as if they have not generated any pseudo-random numbers relative to their current sub-stream. Note: This call only effects previously provided streams.

Link copied to clipboard
open override fun resetRNStreamSequence()

Causes the provider to act as if it has never created any streams. Thus, the next call to nextRNStream() after the reset should return the 1st stream in the sequence of streams that this provider would normally provide in the order in which they would be provided.

Link copied to clipboard
open override fun rnStream(i: Int): RNStreamIfc

Tells the provider to return the ith stream of the sequence of streams that it provides. If i is greater than lastRNStreamNumber() then lastRNStreamNumber() is advanced according to the additional number of streams. For example, if lastRNStreamNumber() = 10 and i = 15, then streams 11, 12, 13, 14, 15 are assumed provided and stream 15 is returned and lastRNStreamNumber() now equals 15. If i is less than or equal to lastRNStreamNumber(), then no new streams are created, lastRNStreamNumber() stays at its current value and the ith stream is returned.

Link copied to clipboard

Causes all streams that have been provided to change their antithetic option to the supplied value. Any new streams provided after this call will not necessarily have the same antithetic option as previous streams if this method is called in the interim. Note: This call only effects previously provided streams.

Link copied to clipboard
open override fun streamNumber(stream: RNStreamIfc): Int