Class DefaultRandom
- java.lang.Object
-
- edu.rit.util.Random
-
- edu.rit.util.DefaultRandom
-
- All Implemented Interfaces:
- java.io.Serializable
public class DefaultRandom extends Random
Class DefaultRandom provides a default pseudorandom number generator (PRNG) designed for use in parallel scientific programming. To create an instance of class DefaultRandom, either use the DefaultRandom() constructor, or use the static getInstance(long) method in class Random.Class DefaultRandom generates random numbers by hashing successive counter values. The seed initializes the counter. The hash function is defined in W. Press et al., Numerical Recipes: The Art of Scientific Computing, Third Edition (Cambridge University Press, 2007), page 352. The hash function applied to the counter value i is:
x := 3935559000370003845 * i + 2691343689449507681 (mod 264)
x := x xor (x right-shift 21)
x := x xor (x left-shift 37)
x := x xor (x right-shift 4)
x := 4768777513237032717 * x (mod 264)
x := x xor (x left-shift 20)
x := x xor (x right-shift 41)
x := x xor (x left-shift 5)
Return x(The shift and arithmetic operations are all performed on unsigned 64-bit numbers.)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DefaultRandom(long seed)Construct a new PRNG with the given seed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidsetSeed(long seed)Set this PRNG's seed.-
Methods inherited from class edu.rit.util.Random
getInstance, getInstance, nextBoolean, nextBoolean, nextByte, nextByte, nextCharacter, nextCharacter, nextDouble, nextDouble, nextFloat, nextFloat, nextInt, nextInt, nextInteger, nextInteger, nextLong, nextLong, nextShort, nextShort, nextUnsignedByte, nextUnsignedByte, nextUnsignedShort, nextUnsignedShort, skip, skip
-
-
DMelt 3.0 © DataMelt by jWork.ORG