escript  Revision_
maths.h
Go to the documentation of this file.
00001 
00002 /*****************************************************************************
00003 *
00004 * Copyright (c) 2003-2014 by University of Queensland
00005 * http://www.uq.edu.au
00006 *
00007 * Primary Business: Queensland, Australia
00008 * Licensed under the Open Software License version 3.0
00009 * http://www.opensource.org/licenses/osl-3.0.php
00010 *
00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
00012 * Development 2012-2013 by School of Earth Sciences
00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
00014 *
00015 *****************************************************************************/
00016 
00017 
00018 #ifndef INC_ESYS_MATHS
00019 #define INC_ESYS_MATHS
00020 
00021 /************************************************************************************/
00022 
00023 /*    Pull in a maths library and define ISNAN      */
00024 
00025 
00026 /* some system values */
00027 /* FIXME: This is not satisfactory.                                */
00028 /* _ECC, __INTEL_COMPILER, and other                               */
00029 /* intel compiler pre-defines need to be handled                   */
00030 /* (__ICL, __ICC come to mind)                                     */
00031 #if defined(_WIN32) && defined(__INTEL_COMPILER)
00032 #include <mathimf.h>
00033 #else
00034 #include <cmath>
00035 #endif
00036 
00037 /*#ifndef NAN
00038    #define NAN (0.0/0.0)
00039 #endif
00040 */
00041 /*#define IS_NAN(__VAL__)  ( (__VAL__) == NAN )*/  /* this does not work */
00042 /* #define IS_NAN(__VAL__)  ( ! ( ( (__VAL__) >= 0. ) ||  ( (__VAL__) <= 0. ) ) )  this does not work */
00043 
00044 #ifdef isnan
00045   #define IS_NAN(__VAL__) (isnan(__VAL__))
00046 #elif defined _isnan
00047   #define IS_NAN(__VAL__) (_isnan(__VAL__))
00048 #else
00049   // This is not guaranteed to work if the optimiser thinks it can optimise this check away
00050   #define IS_NAN(__VAL__) (!((__VAL__)==(__VAL__)))
00051 #endif
00052 
00053 
00054 #define EPSILON DBL_EPSILON
00055 #define LARGE_POSITIVE_FLOAT DBL_MAX
00056 #define SMALL_NEGATIVE_FLOAT -DBL_MAX
00057 
00058 #endif