ESScript  Revision_4488
maths.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 
17 #ifndef INC_ESYS_MATHS
18 #define INC_ESYS_MATHS
19 
20 /************************************************************************************/
21 
22 /* Pull in a maths library and define ISNAN */
23 
24 
25 /* some system values */
26 /* FIXME: This is not satisfactory. */
27 /* _ECC, __INTEL_COMPILER, and other */
28 /* intel compiler pre-defines need to be handled */
29 /* (__ICL, __ICC come to mind) */
30 #if defined(_WIN32) && defined(__INTEL_COMPILER)
31 #include <mathimf.h>
32 #else
33 #include <math.h>
34 #endif
35 
36 /*#ifndef NAN
37  #define NAN (0.0/0.0)
38 #endif
39 */
40 /*#define IS_NAN(__VAL__) ( (__VAL__) == NAN )*/ /* this does not work */
41 /* #define IS_NAN(__VAL__) ( ! ( ( (__VAL__) >= 0. ) || ( (__VAL__) <= 0. ) ) ) this does not work */
42 
43 #ifdef isnan
44  #define IS_NAN(__VAL__) (isnan(__VAL__))
45 #elif defined _isnan
46  #define IS_NAN(__VAL__) (_isnan(__VAL__))
47 #else
48 /* If we do not have isnan then we can't reliably check for NaN - return false */
49  #define IS_NAN(__VAL__) (0)
50 #endif
51 
52 
53 #define EPSILON DBL_EPSILON
54 #define LARGE_POSITIVE_FLOAT DBL_MAX
55 #define SMALL_NEGATIVE_FLOAT -DBL_MAX
56 
57 #endif