示例#1
0
文件: init2d.c 项目: lemahdi/mglib
int 
gsl_histogram2d_set_ranges_uniform (gsl_histogram2d * h, 
                                    double xmin, double xmax,
                                    double ymin, double ymax)
{
  size_t i;
  const size_t nx = h->nx, ny = h->ny;

  if (xmin >= xmax)
    {
      GSL_ERROR_VAL ("xmin must be less than xmax", GSL_EINVAL, 0);
    }

  if (ymin >= ymax)
    {
      GSL_ERROR_VAL ("ymin must be less than ymax", GSL_EINVAL, 0);
    }

  /* initialize ranges */

  make_uniform (h->xrange, nx, xmin, xmax);
  make_uniform (h->yrange, ny, ymin, ymax);

  /* clear contents */

  for (i = 0; i < nx * ny; i++)
    {
      h->bin[i] = 0;
    }

  return GSL_SUCCESS;
}
示例#2
0
文件: init2d.c 项目: lemahdi/mglib
gsl_histogram2d *
gsl_histogram2d_calloc_uniform (const size_t nx, const size_t ny,
                                const double xmin, const double xmax,
                                const double ymin, const double ymax)
{
  gsl_histogram2d *h;

  if (xmin >= xmax)
    {
      GSL_ERROR_VAL ("xmin must be less than xmax", GSL_EINVAL, 0);
    }

  if (ymin >= ymax)
    {
      GSL_ERROR_VAL ("ymin must be less than ymax", GSL_EINVAL, 0);
    }

  h = gsl_histogram2d_calloc (nx, ny);

  if (h == 0)
    {
      return h;
    }

  make_uniform (h->xrange, nx, xmin, xmax);
  make_uniform (h->yrange, ny, ymin, ymax);

  return h;
}
示例#3
0
gsl_histogram *
gsl_histogram_calloc_uniform (const size_t n, const double xmin,
                              const double xmax)
{
  gsl_histogram *h;

  if (xmin >= xmax)
    {
      GSL_ERROR_VAL ("xmin must be less than xmax", GSL_EINVAL, 0);
    }

  h = gsl_histogram_calloc (n);

  if (h == 0)
    {
      return h;
    }

  make_uniform (h->range, n, xmin, xmax);

  return h;
}
示例#4
0
tak_histogram* tak_histogram_calloc_uniform(int n, double xmin, double xmax){
  
  if (xmin >= xmax){
	printf("xmin = %f, xmax = %f\n", xmin, xmax);
    fprintf(stdout,"xmin must be less than xmax for histogram\n");
    exit(10);
  }

  tak_histogram *h;
  double bin_width;
  
  h=tak_histogram_calloc(n);
  if (h == 0 || h == NULL) return h;
  
  make_uniform(h->vbin,n,xmin,xmax,&bin_width);

  h->xmin = xmin;
  h->xmax = xmax;
  h->bin_width = bin_width;

  return h;
}
示例#5
0
int 
gsl_histogram_set_ranges_uniform (gsl_histogram * h, double xmin, double xmax)
{
  size_t i;
  const size_t n = h->n;

  if (xmin >= xmax)
    {
      GSL_ERROR ("xmin must be less than xmax", GSL_EINVAL);
    }

  /* initialize ranges */

  make_uniform (h->range, n, xmin, xmax);

  /* clear contents */

  for (i = 0; i < n; i++)
    {
      h->bin[i] = 0;
    }

  return GSL_SUCCESS;
}