umontreal.iro.lecuyer.rng
Class LFSR258
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.RandomStreamBase
-
- umontreal.iro.lecuyer.rng.LFSR258
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CloneableRandomStream, RandomStream
public class LFSR258 extends RandomStreamBase
ExtendsRandomStreamBaseusing a 64-bit composite linear feedback shift register (LFSR) (or Tausworthe) RNG as defined in. This generator is the LFSR258 proposed in. It has five components combined by a bitwise xor. Its period length is approximatively 2^258 . The values of V, W and Z are 2100, 2100 and 2200 respectively (seeRandomStreamfor their definition). The seed of the RNG, and the state of a stream at any given step, are five-dimensional vectors of 32-bit integers. The default initial seed of the RNG is (1234567890, 1234567890, 1234567890, 1234567890, 1234567890). The nextValue method returns numbers with 53 bits of precision. This generator is fast for 64-bit machines.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description LFSR258()Constructs a new stream.LFSR258(java.lang.String name)Constructs a new stream with the identifier name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description LFSR258clone()Clones the current generator and return its copy.long[]getState()Returns the current state of the stream, represented as an array of five integers.intnextInt(int i, int j)Calls nextDouble once to create one integer between i and j.voidresetNextSubstream()Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.voidresetStartStream()Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.voidresetStartSubstream()Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.static voidsetPackageSeed(long[] seed)Sets the initial seed for the class LFSR258 to the five integers of array seed[0..4].voidsetSeed(long[] seed)This method is discouraged for normal use.java.lang.StringtoString()Returns a string containing the current state of this stream.-
Methods inherited from class umontreal.iro.lecuyer.rng.RandomStreamBase
formatState, formatStateFull, increasedPrecision, nextArrayOfDouble, nextArrayOfInt, nextDouble
-
-
-
-
Constructor Detail
-
LFSR258
public LFSR258()
Constructs a new stream.
-
LFSR258
public LFSR258(java.lang.String name)
Constructs a new stream with the identifier name.- Parameters:
name- name of the stream
-
-
Method Detail
-
setPackageSeed
public static void setPackageSeed(long[] seed)
Sets the initial seed for the class LFSR258 to the five integers of array seed[0..4]. This will be the initial state (or seed) of the next created stream. The default seed for the first stream is (1234567890, 1234567890, 1234567890, 1234567890, 1234567890). The first, second, third, fourth and fifth integers of seed must be either negative, or greater than or equal to 2, 512, 4096, 131072 and 8388608 respectively.- Parameters:
seed- array of 5 elements representing the seed
-
setSeed
public void setSeed(long[] seed)
This method is discouraged for normal use. Initializes the stream at the beginning of a stream with the initial seed seed[0..4]. The seed must satisfy the same conditions as in setPackageSeed. This method only affects the specified stream; the others are not modified, so the beginning of the streams will not be spaced Z values apart. For this reason, this method should only be used in very exceptional cases; proper use of the reset... methods and of the stream constructor is preferable.- Parameters:
seed- array of 5 elements representing the seed
-
getState
public long[] getState()
Returns the current state of the stream, represented as an array of five integers.- Returns:
- the current state of the stream
-
clone
public LFSR258 clone()
Clones the current generator and return its copy.- Specified by:
clonein interfaceCloneableRandomStream- Overrides:
clonein classRandomStreamBase- Returns:
- A deep copy of the current generator
-
resetStartStream
public void resetStartStream()
Description copied from interface:RandomStreamReinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.- Specified by:
resetStartStreamin interfaceRandomStream- Specified by:
resetStartStreamin classRandomStreamBase
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its current substream: Cg is set to Bg.- Specified by:
resetStartSubstreamin interfaceRandomStream- Specified by:
resetStartSubstreamin classRandomStreamBase
-
resetNextSubstream
public void resetNextSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.- Specified by:
resetNextSubstreamin interfaceRandomStream- Specified by:
resetNextSubstreamin classRandomStreamBase
-
toString
public java.lang.String toString()
Description copied from interface:RandomStreamReturns a string containing the current state of this stream.- Specified by:
toStringin interfaceRandomStream- Specified by:
toStringin classRandomStreamBase- Returns:
- the state of the generator formated as a string
-
nextInt
public int nextInt(int i, int j)Description copied from class:RandomStreamBaseCalls nextDouble once to create one integer between i and j. This method always uses the highest order bits of the random number. It should be overridden if a faster implementation exists for the specific generator.- Specified by:
nextIntin interfaceRandomStream- Overrides:
nextIntin classRandomStreamBase- Parameters:
i- the smallest possible returned integerj- the largest possible returned integer- Returns:
- a random integer between i and j
-
-
DMelt 3.0 © DataMelt by jWork.ORG