/* nag_ran_sample_vec (g05ejc) Example Program. * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. */ #include #include #include #include #define NMAX 8 int main(void) { Integer i, n, m, k; Integer ia[NMAX], ib[NMAX]; Integer seed = 0; Vprintf("nag_ran_sample_vec (g05ejc) Example Program Results\n"); /* nag_random_init_repeatable (g05cbc). * Initialize random number generating functions to give * repeatable sequence */ nag_random_init_repeatable(seed); n = NMAX; for (i = 0; i < n; ++i) ia[i] = i; Vprintf("\nSamples from the first %ld integers \n\n", n); Vprintf("Sample size Values \n"); for (m = 1; m <= n; ++m) { /* nag_ran_sample_vec (g05ejc). * Pseudo-random sample without replacement from an integer * vector */ nag_ran_sample_vec(ia, n, ib, m, NAGERR_DEFAULT); Vprintf(" %ld ", m); for (k = 0; k < m; ++k) Vprintf("%ld ",ib[k]); Vprintf("\n"); } return EXIT_SUCCESS; }