From: Ben Pfaff Date: Fri, 16 May 2008 05:35:09 +0000 (+0000) Subject: Use gsl_isnan instead of isnan, gsl_isinf instead of isinf, and X-Git-Tag: v0.6.0~11 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9afcdd223cc1c1b7889601e405cff0bd47300d7;p=pspp-builds.git Use gsl_isnan instead of isnan, gsl_isinf instead of isinf, and gsl_finite instead of finite, as a stopgap measure for portability until appropriate gnulib modules are available. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 064108a4..c0479931 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,14 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * data-out.c (output_infinite): Use gsl_isnan instead of isnan, + and gsl_isinf instead of isinf, as a stopgap measure for + portability until appropriate gnulib modules are available. + + * por-file-writer.c (format_trig_double): Similarly, use + gsl_finite instead of finite. + 2008-03-18 John Darrington * data-in.c: If category is custom currency, then use diff --git a/src/data/data-out.c b/src/data/data-out.c index 86688a67..cef44520 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -927,9 +928,9 @@ output_infinite (double number, const struct fmt_spec *format, char *output) { const char *s; - if (isnan (number)) + if (gsl_isnan (number)) s = "NaN"; - else if (isinf (number)) + else if (gsl_isinf (number)) s = number > 0 ? "+Infinity" : "-Infinity"; else s = "Unknown"; diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 1f348f67..75022ea7 100644 --- a/src/data/por-file-writer.c +++ b/src/data/por-file-writer.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -777,7 +778,7 @@ format_trig_double (long double value, int base_10_precision, char output[]) 0...30**6, an invariant of the loop below. */ errno = 0; base_2_sig = frexp (value, &base_2_exp); - if (errno != 0 || !finite (base_2_sig)) + if (errno != 0 || !gsl_finite (base_2_sig)) goto missing_value; if (base_2_exp == 0 && base_2_sig == 0.) goto zero; diff --git a/src/language/control/ChangeLog b/src/language/control/ChangeLog index ecdcc658..3421bdf4 100644 --- a/src/language/control/ChangeLog +++ b/src/language/control/ChangeLog @@ -1,3 +1,11 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * loop.c (loop_trns_proc): Use gsl_finite instead of finite, , as + a stopgap measure for portability until appropriate gnulib modules + are available. + 2007-09-23 Ben Pfaff Bug #21111. Reviewed by John Darrington. diff --git a/src/language/control/loop.c b/src/language/control/loop.c index ea020a25..c6309d42 100644 --- a/src/language/control/loop.c +++ b/src/language/control/loop.c @@ -17,6 +17,9 @@ #include #include "control-stack.h" + +#include + #include #include #include @@ -320,7 +323,8 @@ loop_trns_proc (void *loop_, struct ccase *c, casenumber case_num) case_data_rw (c, loop->index_var)->f = loop->cur; /* Throw out pathological cases. */ - if (!finite (loop->cur) || !finite (loop->by) || !finite (loop->last) + if (!gsl_finite (loop->cur) || !gsl_finite (loop->by) + || !gsl_finite (loop->last) || loop->by == 0.0 || (loop->by > 0.0 && loop->cur > loop->last) || (loop->by < 0.0 && loop->cur < loop->last)) diff --git a/src/language/data-io/ChangeLog b/src/language/data-io/ChangeLog index 21759bbb..1eda1c05 100644 --- a/src/language/data-io/ChangeLog +++ b/src/language/data-io/ChangeLog @@ -1,3 +1,11 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * inpt-pgm.c (reread_trns_proc): Use gsl_finite instead of finite, + as a stopgap measure for portability until appropriate gnulib + modules are available. + 2008-02-06 John Darrington * get-data.c: Add a /BSIZE subcommand to PSQL reader. diff --git a/src/language/data-io/inpt-pgm.c b/src/language/data-io/inpt-pgm.c index b8a31eae..e000a0fd 100644 --- a/src/language/data-io/inpt-pgm.c +++ b/src/language/data-io/inpt-pgm.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -332,7 +333,7 @@ reread_trns_proc (void *t_, struct ccase *c, casenumber case_num) else { double column = expr_evaluate_num (t->column, c, case_num); - if (!finite (column) || column < 1) + if (!gsl_finite (column) || column < 1) { msg (SE, _("REREAD: Column numbers must be positive finite " "numbers. Column set to 1.")); diff --git a/src/language/expressions/ChangeLog b/src/language/expressions/ChangeLog index a59accb6..18c9441f 100644 --- a/src/language/expressions/ChangeLog +++ b/src/language/expressions/ChangeLog @@ -1,3 +1,13 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * evaluate.c (expr_evaluate): Use gsl_finite instead of finite, as + a stopgap measure for portability until appropriate gnulib modules + are available. + + * helpers.h (copy_string): Ditto. + 2007-10-12 Ben Pfaff Patch #6224. diff --git a/src/language/expressions/evaluate.c b/src/language/expressions/evaluate.c index a0a133ad..6402cc0a 100644 --- a/src/language/expressions/evaluate.c +++ b/src/language/expressions/evaluate.c @@ -18,6 +18,7 @@ #include "private.h" #include +#include #include #include #include "helpers.h" @@ -63,7 +64,7 @@ expr_evaluate (struct expression *e, const struct ccase *c, int case_idx, break; case OP_return_number: - *(double *) result = finite (ns[-1]) ? ns[-1] : SYSMIS; + *(double *) result = gsl_finite (ns[-1]) ? ns[-1] : SYSMIS; return; case OP_return_string: diff --git a/src/language/expressions/helpers.h b/src/language/expressions/helpers.h index f856da3a..23ca315a 100644 --- a/src/language/expressions/helpers.h +++ b/src/language/expressions/helpers.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ struct substring copy_string (struct expression *, static inline bool is_valid (double d) { - return finite (d) && d != SYSMIS; + return gsl_finite (d) && d != SYSMIS; } size_t count_valid (double *, size_t); diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index fcd88f1e..229b4f93 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,15 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * hash.c (hsh_hash_int): Use gsl_isnan instead of isnan, as a + stopgap measure for portability until appropriate gnulib modules + are available. + + * misc.h (macro isinf): Remove implementations of isinf, isnan, + and finite, because they were not effective and we are now using + the equivalent GSL functions. + 2008-03-04 Ben Pfaff Patch #6427. Reviewed by John Darrington. diff --git a/src/libpspp/hash.c b/src/libpspp/hash.c index 9da3deb1..627751e1 100644 --- a/src/libpspp/hash.c +++ b/src/libpspp/hash.c @@ -20,6 +20,7 @@ #include "message.h" #include #include +#include #include #include #include @@ -133,7 +134,7 @@ hsh_hash_int (int i) unsigned hsh_hash_double (double d) { - if (!isnan (d)) + if (!gsl_isnan (d)) return hsh_hash_bytes (&d, sizeof d); else return 0; diff --git a/src/libpspp/misc.h b/src/libpspp/misc.h index 69d3dc4f..e33d588f 100644 --- a/src/libpspp/misc.h +++ b/src/libpspp/misc.h @@ -22,24 +22,6 @@ #define EPSILON (10 * DBL_EPSILON) -/* HUGE_VAL is traditionally defined as positive infinity, or - alternatively, DBL_MAX. */ -#if !HAVE_ISINF && !defined isinf -#define isinf(X) (fabs (X) == HUGE_VAL) -#endif - -/* A Not a Number is not equal to itself. */ -#if !HAVE_ISNAN && !defined isnan -#define isnan(X) ((X) != (X)) -#endif - -/* Finite numbers are not infinities or NaNs. */ -#if !HAVE_FINITE && !defined finite -#define finite(X) (!isinf (X) && !isnan (X)) -#elif HAVE_IEEEFP_H -#include /* Declares finite() under Solaris. */ -#endif - /* Divides nonnegative X by positive Y, rounding up. */ #define DIV_RND_UP(X, Y) (((X) + ((Y) - 1)) / (Y)) diff --git a/src/math/ChangeLog b/src/math/ChangeLog index 1d3b95bb..c1cd1a3a 100644 --- a/src/math/ChangeLog +++ b/src/math/ChangeLog @@ -1,3 +1,11 @@ +2008-05-15 Ben Pfaff + + Patch #6512. + + * moments.c (calc_moments): Use gsl_finite instead of finite, as a + stopgap measure for portability until appropriate gnulib modules + are available. + 2008-03-10 Jason Stover * coefficient.c (pspp_linreg_get_coeff): Removed use of diff --git a/src/math/moments.c b/src/math/moments.c index 084e6d8c..02208bca 100644 --- a/src/math/moments.c +++ b/src/math/moments.c @@ -17,6 +17,7 @@ #include #include "moments.h" #include +#include #include #include #include @@ -55,7 +56,7 @@ calc_moments (enum moment max_moment, { double s3 = s2 * sqrt (s2); double g1 = (w * d3) / ((w - 1.0) * (w - 2.0) * s3); - if (finite (g1)) + if (gsl_finite (g1)) *skewness = g1; } if (max_moment >= MOMENT_KURTOSIS && kurtosis != NULL && w > 3.) @@ -63,7 +64,7 @@ calc_moments (enum moment max_moment, double den = (w - 2.) * (w - 3.) * pow2 (s2); double g2 = (w * (w + 1) * d4 / (w - 1.) / den - 3. * pow2 (d2) / den); - if (finite (g2)) + if (gsl_finite (g2)) *kurtosis = g2; } }