예제 #1
0
        /// <summary>
        /// Creates an array that contains a random permutation of the
        /// numbers in the interval [0, count-1].
        /// </summary>
        public static long[] CreatePermutationArrayLong(
            this IRandomUniform rnd, long count)
        {
            var p = new long[count].SetByIndexLong(i => i);

            rnd.Randomize(p);
            return(p);
        }
예제 #2
0
        /// <summary>
        /// Creates an array that contains a random permutation of the
        /// ints in the interval [0, count-1].
        /// </summary>
        public static int[] CreatePermutationArray(
            this IRandomUniform rnd, int count)
        {
            var p = new int[count].SetByIndex(i => i);

            rnd.Randomize(p);
            return(p);
        }
예제 #3
0
 /// <summary>
 /// Randomly permute the elements of the supplied array. This does
 /// work with arrays up to a length of about 2^50.
 /// </summary>
 public static void Randomize <T>(
     this IRandomUniform rnd, T[] array)
 {
     rnd.Randomize(array, array.LongLength);
 }