Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / include / R_ext / Arith.h @ 2486

History | View | Annotate | Download (2.7 kB)

1 2486 sjacqu01
/*
2 2486 sjacqu01
 *  R : A Computer Language for Statistical Data Analysis
3 2486 sjacqu01
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4 2486 sjacqu01
 *  Copyright (C) 1998--2007  The R Core Team.
5 2486 sjacqu01
 *
6 2486 sjacqu01
 *  This program is free software; you can redistribute it and/or modify
7 2486 sjacqu01
 *  it under the terms of the GNU Lesser General Public License as published by
8 2486 sjacqu01
 *  the Free Software Foundation; either version 2.1 of the License, or
9 2486 sjacqu01
 *  (at your option) any later version.
10 2486 sjacqu01
 *
11 2486 sjacqu01
 *  This program is distributed in the hope that it will be useful,
12 2486 sjacqu01
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 2486 sjacqu01
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 2486 sjacqu01
 *  GNU Lesser General Public License for more details.
15 2486 sjacqu01
 *
16 2486 sjacqu01
 *  You should have received a copy of the GNU Lesser General Public License
17 2486 sjacqu01
 *  along with this program; if not, a copy is available at
18 2486 sjacqu01
 *  http://www.r-project.org/Licenses/
19 2486 sjacqu01
 */
20 2486 sjacqu01
21 2486 sjacqu01
/* Included by R.h: API */
22 2486 sjacqu01
23 2486 sjacqu01
#ifndef R_ARITH_H_
24 2486 sjacqu01
#define R_ARITH_H_
25 2486 sjacqu01
26 2486 sjacqu01
/* Only for use where config.h has not already been included */
27 2486 sjacqu01
#if defined(HAVE_GLIBC2) && !defined(_BSD_SOURCE)
28 2486 sjacqu01
/* ensure that finite and isnan are declared */
29 2486 sjacqu01
# define _BSD_SOURCE 1
30 2486 sjacqu01
#endif
31 2486 sjacqu01
32 2486 sjacqu01
#include <R_ext/libextern.h>
33 2486 sjacqu01
#ifdef  __cplusplus
34 2486 sjacqu01
extern "C" {
35 2486 sjacqu01
#elif !defined(NO_C_HEADERS)
36 2486 sjacqu01
/* needed for isnan and isfinite, neither of which are used under C++ */
37 2486 sjacqu01
# include <math.h>
38 2486 sjacqu01
#endif
39 2486 sjacqu01
40 2486 sjacqu01
/* implementation of these : ../../main/arithmetic.c */
41 2486 sjacqu01
LibExtern double R_NaN;                /* IEEE NaN */
42 2486 sjacqu01
LibExtern double R_PosInf;        /* IEEE Inf */
43 2486 sjacqu01
LibExtern double R_NegInf;        /* IEEE -Inf */
44 2486 sjacqu01
LibExtern double R_NaReal;        /* NA_REAL: IEEE */
45 2486 sjacqu01
LibExtern int         R_NaInt;        /* NA_INTEGER:= INT_MIN currently */
46 2486 sjacqu01
#ifdef __MAIN__
47 2486 sjacqu01
#undef extern
48 2486 sjacqu01
#undef LibExtern
49 2486 sjacqu01
#endif
50 2486 sjacqu01
51 2486 sjacqu01
#define NA_LOGICAL        R_NaInt
52 2486 sjacqu01
#define NA_INTEGER        R_NaInt
53 2486 sjacqu01
/* #define NA_FACTOR        R_NaInt  unused */
54 2486 sjacqu01
#define NA_REAL                R_NaReal
55 2486 sjacqu01
/* NA_STRING is a SEXP, so defined in Rinternals.h */
56 2486 sjacqu01
57 2486 sjacqu01
int R_IsNA(double);                /* True for R's NA only */
58 2486 sjacqu01
int R_IsNaN(double);                /* True for special NaN, *not* for NA */
59 2486 sjacqu01
int R_finite(double);                /* True if none of NA, NaN, +/-Inf */
60 2486 sjacqu01
#define ISNA(x)               R_IsNA(x)
61 2486 sjacqu01
62 2486 sjacqu01
/* ISNAN(): True for *both* NA and NaN.
63 2486 sjacqu01
   NOTE: some systems do not return 1 for TRUE.
64 2486 sjacqu01
   Also note that C++ math headers specifically undefine
65 2486 sjacqu01
   isnan if it is a macro (it is on OS X and in C99),
66 2486 sjacqu01
   hence the workaround.  This code also appears in Rmath.h
67 2486 sjacqu01
*/
68 2486 sjacqu01
#ifdef __cplusplus
69 2486 sjacqu01
  int R_isnancpp(double); /* in arithmetic.c */
70 2486 sjacqu01
#  define ISNAN(x)     R_isnancpp(x)
71 2486 sjacqu01
#else
72 2486 sjacqu01
#  define ISNAN(x)     (isnan(x)!=0)
73 2486 sjacqu01
#endif
74 2486 sjacqu01
75 2486 sjacqu01
/* The following is only defined inside R */
76 2486 sjacqu01
#ifdef HAVE_WORKING_ISFINITE
77 2486 sjacqu01
/* isfinite is defined in <math.h> according to C99 */
78 2486 sjacqu01
# define R_FINITE(x)    isfinite(x)
79 2486 sjacqu01
#else
80 2486 sjacqu01
# define R_FINITE(x)    R_finite(x)
81 2486 sjacqu01
#endif
82 2486 sjacqu01
83 2486 sjacqu01
#ifdef  __cplusplus
84 2486 sjacqu01
}
85 2486 sjacqu01
#endif
86 2486 sjacqu01
87 2486 sjacqu01
#endif /* R_ARITH_H_ */