Function rgsl::randist::shuffling_sampling::shuffle [] [src]

pub fn shuffle<T>(r: &Rng, base: &mut [T])

This function randomly shuffles the order of n objects, each of size size, stored in the array base[0..n-1]. The output of the random number generator r is used to produce the permutation. The algorithm generates all possible n! permutations with equal probability, assuming a perfect source of random numbers.

The following code shows how to shuffle the numbers from 0 to 51,

int a[52];
 
for (i = 0; i < 52; i++)
  {
    a[i] = i;
  }
 
gsl_ran_shuffle (r, a, 52, sizeof (int));