GSL直方图Histogram 1

来源:互联网 发布:手机数据上网慢怎么办 编辑:程序博客网 时间:2024/06/06 21:39
#include <stdio.h>#include <stdlib.h>#include <gsl/gsl_histogram.h>#pragma comment(lib, "libgsl_d.lib")#pragma comment(lib, "libgslcblas_d.lib")intmain (int argc, char **argv){  double a, b;  size_t n;  if (argc != 4)    {      printf ("Usage: gsl-histogram xmin xmax n\n"              "Computes a histogram of the data "              "on stdin using n bins from xmin "              "to xmax\n");      exit (0);    }  a = atof (argv[1]);  b = atof (argv[2]);  n = atoi (argv[3]);  {    double x;    gsl_histogram * h = gsl_histogram_alloc (n);    gsl_histogram_set_ranges_uniform (h, a, b);    while (fscanf (stdin, "%lg", &x) == 1)      {        gsl_histogram_increment (h, x);      }    gsl_histogram_fprintf (stdout, h, "%g", "%g");    gsl_histogram_free (h);  }  exit (0);}

原创粉丝点击