X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fhistogram.c;h=1b55d204b866fa2e15dc4ff3f84d3b3a509a9915;hb=81579d9e9f994fb2908f50af41c3eb033d216e58;hp=c41bdc08508bc8be9e9f3d0b8b55f33fdf3cc79b;hpb=b46b794dfb9f0758aafec83f50993d1930894099;p=pspp-builds.git
diff --git a/src/math/histogram.c b/src/math/histogram.c
index c41bdc08..1b55d204 100644
--- a/src/math/histogram.c
+++ b/src/math/histogram.c
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2008, 2009, 2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,15 +15,17 @@
along with this program. If not, see . */
#include
-#include "histogram.h"
-#include
-#include
+#include "math/histogram.h"
#include
-#include "chart-geometry.h"
#include
+#include "libpspp/assertion.h"
+#include "libpspp/cast.h"
+#include "math/chart-geometry.h"
+
+#include "gl/xalloc.h"
void
histogram_add (struct histogram *h, double y, double c)
@@ -37,7 +39,7 @@ histogram_add (struct histogram *h, double y, double c)
static void
acc (struct statistic *s, const struct ccase *cx UNUSED, double c, double cc UNUSED, double y)
{
- struct histogram *hist = (struct histogram *) s;
+ struct histogram *hist = UP_CAST (s, struct histogram, parent);
gsl_histogram_accumulate (hist->gsl_hist, y, c);
}
@@ -46,7 +48,7 @@ acc (struct statistic *s, const struct ccase *cx UNUSED, double c, double cc UNU
static void
destroy (struct statistic *s)
{
- struct histogram *h = (struct histogram *) s;
+ struct histogram *h = UP_CAST (s, struct histogram, parent);
gsl_histogram_free (h->gsl_hist);
free (s);
}
@@ -64,7 +66,7 @@ histogram_create (int bins, double min, double max)
int n = ceil (max / (bin_width_2) ) ;
- assert (max > min);
+ assert (max >= min);
if ( ! (n % 2 ) ) n++;
upper_limit = n * bin_width_2;