escript  Revision_4925
maths.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 
18 #ifndef INC_ESYS_MATHS
19 #define INC_ESYS_MATHS
20 
21 /************************************************************************************/
22 
23 /* Pull in a maths library and define ISNAN */
24 
25 
26 /* some system values */
27 /* FIXME: This is not satisfactory. */
28 /* _ECC, __INTEL_COMPILER, and other */
29 /* intel compiler pre-defines need to be handled */
30 /* (__ICL, __ICC come to mind) */
31 #if defined(_WIN32) && defined(__INTEL_COMPILER)
32 #include <mathimf.h>
33 #else
34 #include <cmath>
35 #endif
36 
37 /*#ifndef NAN
38  #define NAN (0.0/0.0)
39 #endif
40 */
41 /*#define IS_NAN(__VAL__) ( (__VAL__) == NAN )*/ /* this does not work */
42 /* #define IS_NAN(__VAL__) ( ! ( ( (__VAL__) >= 0. ) || ( (__VAL__) <= 0. ) ) ) this does not work */
43 
44 #ifdef isnan
45  #define IS_NAN(__VAL__) (isnan(__VAL__))
46 #elif defined _isnan
47  #define IS_NAN(__VAL__) (_isnan(__VAL__))
48 #else
49  // This is not guaranteed to work if the optimiser thinks it can optimise this check away
50  #define IS_NAN(__VAL__) (!((__VAL__)==(__VAL__)))
51 #endif
52 
53 
54 #define EPSILON DBL_EPSILON
55 #define LARGE_POSITIVE_FLOAT DBL_MAX
56 #define SMALL_NEGATIVE_FLOAT -DBL_MAX
57 
58 #endif