Class IntJumpDistances
- java.lang.Object
-
- org.apache.commons.rng.core.source32.IntJumpDistances
-
final class IntJumpDistances extends java.lang.ObjectUtility for working with positive integer jump distances represented as 32-bit integers.- Since:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private static longMANTISSA_MASKMask to extract the 52-bit mantissa from a long representation of a double.private static intNAN_EXPThe value of the exponent for NaN when the exponent is extracted and scaled to account for multiplying the floating-point 52-bit mantissa to an integer.private static doubleTWO_POW_632^63.
-
Constructor Summary
Constructors Modifier Constructor Description privateIntJumpDistances()Class contains only static methods.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidvalidateJump(double distance, double period)Validate the jumpdistanceis valid within the givenperiodof the cycle.(package private) static voidvalidateJumpPowerOfTwo(int logDistance, int logPeriod)Validate the jump distance of 2logDistanceis valid within the given cycle period of 2logPeriod.(package private) static voidwriteUnsignedInteger(double value, int[] result)Write thevalueto an unsigned integer representation.
-
-
-
Field Detail
-
TWO_POW_63
private static final double TWO_POW_63
2^63.- See Also:
- Constant Field Values
-
NAN_EXP
private static final int NAN_EXP
The value of the exponent for NaN when the exponent is extracted and scaled to account for multiplying the floating-point 52-bit mantissa to an integer. 1024 - 52 = 972.- See Also:
- Constant Field Values
-
MANTISSA_MASK
private static final long MANTISSA_MASK
Mask to extract the 52-bit mantissa from a long representation of a double.- See Also:
- Constant Field Values
-
-
Method Detail
-
validateJump
static void validateJump(double distance, double period)Validate the jumpdistanceis valid within the givenperiodof the cycle.- Parameters:
distance- Jump distance.period- Cycle period.- Throws:
java.lang.IllegalArgumentException- ifdistanceis negative, or is greater than theperiod.
-
validateJumpPowerOfTwo
static void validateJumpPowerOfTwo(int logDistance, int logPeriod)Validate the jump distance of 2logDistanceis valid within the given cycle period of 2logPeriod.Note: Negative
logDistanceis allowed as the distance is>= 0.- Parameters:
logDistance- Base-2 logarithm of the distance to jump forward with the state cycle.logPeriod- Base-2 logarithm of the cycle period.- Throws:
java.lang.IllegalArgumentException- iflogDistance >= logPeriod.
-
writeUnsignedInteger
static void writeUnsignedInteger(double value, int[] result)Write thevalueto an unsigned integer representation. Any fractional part of the floating-point value is discarded. The integer part of the value must be positive or an exception is raised.The 53-bit significand of the
valueis converted to an integer, shifted to align with a 32-bit boundary and written to the providedresult, ordered with the least significant bits first.No bounds checking is performed. The
resultarray is assumed to have a length of at least 2 to store an unshifted 53-bit significand. The required array size for values larger than 2^53 can be computed using:1 + Math.getExponent(value) / 32
Parts of the array not used by the significand are unchanged. It is recommended to use a newly created array for the result.
Note: For jump distances validated as less than the period of an output cycle the result array length can be preallocated based on the maximum possible length.
- Parameters:
value- Valueresult- the integer representation- Throws:
java.lang.IllegalArgumentException- if thevalueis negative or non-finite.
-
-