Package cc.redberry.rings.util
Class RandomUtil
java.lang.Object
cc.redberry.rings.util.RandomUtil
public final class RandomUtil extends Object
- Since:
- 1.0
-
Method Summary
Modifier and Type Method Description static BigInteger[]
randomBigIntegerArray(int length, BigInteger min, BigInteger max, org.apache.commons.math3.random.RandomGenerator rnd)
Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).static BigInteger
randomInt(BigInteger bound, org.apache.commons.math3.random.RandomGenerator rnd)
Returns random integer in range[0, bound)
.static int[]
randomIntArray(int length, int min, int max, org.apache.commons.math3.random.RandomGenerator rnd)
Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).static long[]
randomLongArray(int length, long min, long max, org.apache.commons.math3.random.RandomGenerator rnd)
Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).static int[]
randomSharpIntArray(int length, int total, org.apache.commons.math3.random.RandomGenerator rnd)
Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).
-
Method Details
-
randomIntArray
public static int[] randomIntArray(int length, int min, int max, org.apache.commons.math3.random.RandomGenerator rnd)Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).- Parameters:
length
- array lengthmin
- min valuemax
- max valuernd
- random source- Returns:
- array of length
length
with elements bounded bybound
(by absolute value)
-
randomSharpIntArray
public static int[] randomSharpIntArray(int length, int total, org.apache.commons.math3.random.RandomGenerator rnd)Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).- Parameters:
length
- array lengthtotal
- totalrnd
- random source- Returns:
- array of length
length
with elements bounded bybound
(by absolute value)
-
randomLongArray
public static long[] randomLongArray(int length, long min, long max, org.apache.commons.math3.random.RandomGenerator rnd)Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).- Parameters:
length
- array lengthmin
- min valuemax
- max valuernd
- random source- Returns:
- array of length
length
with elements bounded bybound
(by absolute value)
-
randomBigIntegerArray
public static BigInteger[] randomBigIntegerArray(int length, BigInteger min, BigInteger max, org.apache.commons.math3.random.RandomGenerator rnd)Creates random array of lengthdegree + 1
with elements bounded bybound
(by absolute value).- Parameters:
length
- array lengthmin
- min valuemax
- max valuernd
- random source- Returns:
- array of length
length
with elements bounded bybound
(by absolute value)
-
randomInt
public static BigInteger randomInt(BigInteger bound, org.apache.commons.math3.random.RandomGenerator rnd)Returns random integer in range[0, bound)
.- Parameters:
bound
- maximal allowed valuernd
- random- Returns:
- a BigInteger
b
so that0 <= b < bound
-