Function malachite_base::num::random::striped::striped_random_fixed_length_unsigned_vecs
source · [−]pub fn striped_random_fixed_length_unsigned_vecs<T: PrimitiveUnsigned>(
seed: Seed,
len: u64,
mean_stripe_numerator: u64,
mean_stripe_denominator: u64
) -> StripedRandomUnsignedVecs<T, Repeat<u64>>ⓘNotable traits for StripedRandomUnsignedVecs<T, I>impl<T: PrimitiveUnsigned, I: Iterator<Item = u64>> Iterator for StripedRandomUnsignedVecs<T, I> type Item = Vec<T>;
Expand description
Generates random striped unsigned Vec
s of a given length.
See here for more information.
The mean run length (before the bit sequences are truncated) is
$m$ = mean_stripe_numerator / mean_stripe_denominator
.
If len
is 0, the output consists of the empty list, repeated.
Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is len
.
Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::striped::striped_random_fixed_length_unsigned_vecs;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::{ToBinaryString, ToDebugString};
assert_eq!(
prefix_to_string(
striped_random_fixed_length_unsigned_vecs::<u8>(EXAMPLE_SEED, 3, 10, 1)
.map(
|xs| prefix_to_string(
xs.into_iter().map(|x: u8| x.to_binary_string()),
100
)
),
10,
),
"[[0, 0, 111000], [0, 11111100, 11], [11111110, 1111, 0], [0, 0, 11111000], \
[0, 0, 1111110], [11111111, 11011111, 11111111], [11110000, 11111111, 11111111], \
[11000011, 11111, 0], [0, 10000000, 11111001], [11111111, 0, 0], ...]"
);