Skip to main content

random_integer_vectors_with_dimension

Function random_integer_vectors_with_dimension 

Source
pub fn random_integer_vectors_with_dimension(
    seed: Seed,
    dimension: u64,
    mean_bits_numerator: u64,
    mean_bits_denominator: u64,
) -> RandomIntegerVectors<RandomFixedLengthVecsFromSingle<RandomVectorElements>> ⓘ
Expand description

Generates random IntegerVectors of a given dimension.

The elements are sampled from random_integers, with a mean bit count of mean_bits_numerator / mean_bits_denominator.

If dimension is 0, the output consists of the 0-dimensional vector, repeated.

The output length is infinite.

§Worst-case complexity per iteration

$T(i) = O(nb)$

$M(i) = O(nb)$

where $T$ is time, $M$ is additional memory, $i$ is the iteration number, $n$ is dimension, and $b$ is mean_bits_numerator / mean_bits_denominator.

§Panics

Panics if mean_bits_numerator or mean_bits_denominator are zero, or if, after being reduced to lowest terms, their sum is greater than or equal to $2^{64}$.

§Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::integer_vector::random::random_integer_vectors_with_dimension;

assert_eq!(
    prefix_to_string(
        random_integer_vectors_with_dimension(EXAMPLE_SEED, 3, 4, 1),
        5
    ),
    "[(2, 152, 1), (0, -62, 5282), (0, 28, 4427344568), (79, -11, -7330), \
    (-1, -5667523, 1618), ...]"
);