Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / doc / examples / histogram.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <gsl/gsl_histogram.h>
4
5 int
6 main (int argc, char **argv)
7 {
8   double a, b;
9   size_t n;
10
11   if (argc != 4)
12     {
13       printf ("Usage: gsl-histogram xmin xmax n\n"
14               "Computes a histogram of the data "
15               "on stdin using n bins from xmin "
16               "to xmax\n");
17       exit (0);
18     }
19
20   a = atof (argv[1]);
21   b = atof (argv[2]);
22   n = atoi (argv[3]);
23
24   {
25     double x;
26     gsl_histogram * h = gsl_histogram_alloc (n);
27     gsl_histogram_set_ranges_uniform (h, a, b);
28
29     while (fscanf (stdin, "%lg", &x) == 1)
30       {
31         gsl_histogram_increment (h, x);
32       }
33     gsl_histogram_fprintf (stdout, h, "%g", "%g");
34     gsl_histogram_free (h);
35   }
36   exit (0);
37 }