3 * Copyright (C) 2001, 2004, 2007 Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 double gsl_nan (void);
28 double gsl_posinf (void);
29 double gsl_neginf (void);
30 double gsl_fdiv (const double x, const double y);
34 return gsl_fdiv (0.0, 0.0);
37 double gsl_posinf (void)
39 return gsl_fdiv (+1.0, 0.0);
42 double gsl_neginf (void)
44 return gsl_fdiv (-1.0, 0.0);
48 int gsl_isnan (const double x);
49 int gsl_isinf (const double x);
50 int gsl_finite (const double x);
52 #if defined(_MSC_VER) /* Microsoft Visual C++ */
55 gsl_isnan (const double x)
61 gsl_isinf (const double x)
63 int fpc = _fpclass(x);
65 if (fpc == _FPCLASS_PINF)
67 else if (fpc == _FPCLASS_NINF)
74 gsl_finite (const double x)
80 # if HAVE_DECL_ISFINITE
82 gsl_finite (const double x)
86 # elif HAVE_DECL_FINITE
88 gsl_finite (const double x)
92 # elif HAVE_IEEE_COMPARISONS
94 gsl_finite (const double x)
96 const double y = x - x;
97 int status = (y == y);
104 gsl_isnan (const double x)
108 #elif HAVE_IEEE_COMPARISONS
110 gsl_isnan (const double x)
112 int status = (x != x);
119 gsl_isinf (const double x)
126 gsl_isinf (const double x)
128 if (! gsl_finite(x) && ! gsl_isnan(x))
130 return (x > 0 ? +1 : -1);