Jngen provides several free functions and a generator class MathRandom to help generating numbers and combinatorial primitives. All interaction with MathRandom goes via its global instance called rndm. The source of randomness is rnd.
- Returns: true if n is prime, false otherwise.
- Supported for all n from 1 to 3.8e18.
- Implemented with deterministic variation of the Miller-Rabin primality test so should work relatively fast (exact benchmark here).
- Returns: random prime in range [2, n) or [l, r] respectively.
- Throws if no prime is found on the interval.
- Returns: the first prime larger (or smaller) than n, including n.
- Returns: a random ordered partition of n into numParts parts, where the size of each part is between minSize and maxSize. If maxSize is -1 (the default value) then sizes can be arbitrary large.
template<typename T>
TArray<TArray<T>> partition(TArray<T> elements, int numParts, int minSize = 0, int maxSize = -1)
- Returns: a random partition of the array elements into numParts parts.
- Returns: a random partition of the array elements into parts, where the size of each part is specified.
- Note: sum(sizes) must be equal to elements.size().