~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to esysUtils/src/maths.h

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

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