Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / doc / examples / permshuffle.c
1 #include <stdio.h>
2 #include <gsl/gsl_rng.h>
3 #include <gsl/gsl_randist.h>
4 #include <gsl/gsl_permutation.h>
5
6 int
7 main (void) 
8 {
9   const size_t N = 10;
10   const gsl_rng_type * T;
11   gsl_rng * r;
12
13   gsl_permutation * p = gsl_permutation_alloc (N);
14   gsl_permutation * q = gsl_permutation_alloc (N);
15
16   gsl_rng_env_setup();
17   T = gsl_rng_default;
18   r = gsl_rng_alloc (T);
19
20   printf ("initial permutation:");  
21   gsl_permutation_init (p);
22   gsl_permutation_fprintf (stdout, p, " %u");
23   printf ("\n");
24
25   printf (" random permutation:");  
26   gsl_ran_shuffle (r, p->data, N, sizeof(size_t));
27   gsl_permutation_fprintf (stdout, p, " %u");
28   printf ("\n");
29
30   printf ("inverse permutation:");  
31   gsl_permutation_inverse (q, p);
32   gsl_permutation_fprintf (stdout, q, " %u");
33   printf ("\n");
34
35   gsl_permutation_free (p);
36   gsl_permutation_free (q);
37   gsl_rng_free (r);
38
39   return 0;
40 }