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
/*
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1998--2007  The R Core Team.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU Lesser General Public License as published by
8
 *  the Free Software Foundation; either version 2.1 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU Lesser General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU Lesser General Public License
17
 *  along with this program; if not, a copy is available at
18
 *  http://www.r-project.org/Licenses/
19
 */
20

    
21
/* Included by R.h: API */
22

    
23
#ifndef R_ARITH_H_
24
#define R_ARITH_H_
25

    
26
/* Only for use where config.h has not already been included */
27
#if defined(HAVE_GLIBC2) && !defined(_BSD_SOURCE)
28
/* ensure that finite and isnan are declared */
29
# define _BSD_SOURCE 1
30
#endif
31

    
32
#include <R_ext/libextern.h>
33
#ifdef  __cplusplus
34
extern "C" {
35
#elif !defined(NO_C_HEADERS)
36
/* needed for isnan and isfinite, neither of which are used under C++ */
37
# include <math.h>
38
#endif
39

    
40
/* implementation of these : ../../main/arithmetic.c */
41
LibExtern double R_NaN;                /* IEEE NaN */
42
LibExtern double R_PosInf;        /* IEEE Inf */
43
LibExtern double R_NegInf;        /* IEEE -Inf */
44
LibExtern double R_NaReal;        /* NA_REAL: IEEE */
45
LibExtern int         R_NaInt;        /* NA_INTEGER:= INT_MIN currently */
46
#ifdef __MAIN__
47
#undef extern
48
#undef LibExtern
49
#endif
50

    
51
#define NA_LOGICAL        R_NaInt
52
#define NA_INTEGER        R_NaInt
53
/* #define NA_FACTOR        R_NaInt  unused */
54
#define NA_REAL                R_NaReal
55
/* NA_STRING is a SEXP, so defined in Rinternals.h */
56

    
57
int R_IsNA(double);                /* True for R's NA only */
58
int R_IsNaN(double);                /* True for special NaN, *not* for NA */
59
int R_finite(double);                /* True if none of NA, NaN, +/-Inf */
60
#define ISNA(x)               R_IsNA(x)
61

    
62
/* ISNAN(): True for *both* NA and NaN.
63
   NOTE: some systems do not return 1 for TRUE.
64
   Also note that C++ math headers specifically undefine
65
   isnan if it is a macro (it is on OS X and in C99),
66
   hence the workaround.  This code also appears in Rmath.h
67
*/
68
#ifdef __cplusplus
69
  int R_isnancpp(double); /* in arithmetic.c */
70
#  define ISNAN(x)     R_isnancpp(x)
71
#else
72
#  define ISNAN(x)     (isnan(x)!=0)
73
#endif
74

    
75
/* The following is only defined inside R */
76
#ifdef HAVE_WORKING_ISFINITE
77
/* isfinite is defined in <math.h> according to C99 */
78
# define R_FINITE(x)    isfinite(x)
79
#else
80
# define R_FINITE(x)    R_finite(x)
81
#endif
82

    
83
#ifdef  __cplusplus
84
}
85
#endif
86

    
87
#endif /* R_ARITH_H_ */