- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/CoinUtils-2.6.1/CoinUtils/src/CoinFinite.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinFinite.hpp 1215 2009-11-05 11:03:04Z forrest $ */
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004
    00005 // Also put all base defines here e.g. VC++ pragmas
    00006 #ifndef CoinFinite_H
    00007 #define CoinFinite_H
    00008
    00009 #include "CoinUtilsConfig.h"
    00010
    00011 #include <cstdlib>
    00012 #ifdef HAVE_CMATH
    00013 # include <cmath>
    00014 #else
    00015 # ifdef HAVE_MATH_H
    00016 #  include <math.h>
    00017 # else
    00018 #  error "don't have header file for math"
    00019 # endif
    00020 #endif
    00021
    00022 #ifdef HAVE_CFLOAT
    00023 # include <cfloat>
    00024 #else
    00025 # ifdef HAVE_FLOAT_H
    00026 #  include <float.h>
    00027 # endif
    00028 #endif
    00029
    00030 #ifdef HAVE_CIEEEFP
    00031 # include <cieeefp>
    00032 #else
    00033 # ifdef HAVE_IEEEFP_H
    00034 #  include <ieeefp.h>
    00035 # endif
    00036 #endif
    00037
    00038 #include <algorithm>
    00039
    00040 //=============================================================================
    00041 // Compilers can produce better code if they know about __restrict
    00042 #ifdef COIN_USE_RESTRICT
    00043 #define COIN_RESTRICT __restrict
    00044 #else
    00045 #define COIN_RESTRICT
    00046 #endif
    00047 //=============================================================================
    00048 // Switch on certain things if COIN_FAST_CODE
    00049 #ifdef COIN_FAST_CODE
    00050 #ifndef COIN_NOTEST_DUPLICATE
    00051 #define COIN_NOTEST_DUPLICATE
    00052 #endif
    00053 #ifndef COIN_USE_EKK_SORT
    00054 #define COIN_USE_EKK_SORT
    00055 #endif
    00056 #endif
    00057 //=============================================================================
    00058 #if COIN_BIG_INDEX==0
    00059 typedef int CoinBigIndex;
    00060 #elif COIN_BIG_INDEX==1
    00061 typedef long CoinBigIndex;
    00062 #else
    00063 typedef long long CoinBigIndex;
    00064 #endif
    00065
    00066 //=============================================================================
    00067 #ifndef COIN_BIG_DOUBLE
    00068 #define COIN_BIG_DOUBLE 0
    00069 #endif
    00070 // See if we want the ability to have long double work arrays
    00071 #if COIN_BIG_DOUBLE==2
    00072 #undef COIN_BIG_DOUBLE
    00073 #define COIN_BIG_DOUBLE 0
    00074 #define COIN_LONG_WORK 1
    00075 typedef long double CoinWorkDouble;
    00076 #elif COIN_BIG_DOUBLE==3
    00077 #undef COIN_BIG_DOUBLE
    00078 #define COIN_BIG_DOUBLE 1
    00079 #define COIN_LONG_WORK 1
    00080 typedef long double CoinWorkDouble;
    00081 #else
    00082 #define COIN_LONG_WORK 0
    00083 typedef double CoinWorkDouble;
    00084 #endif
    00085 #if COIN_BIG_DOUBLE==0
    00086 typedef double CoinFactorizationDouble;
    00087 #elif COIN_BIG_DOUBLE==1
    00088 typedef long double CoinFactorizationDouble;
    00089 #else
    00090 typedef double CoinFactorizationDouble;
    00091 #endif
    00092
    00093 //=============================================================================
    00094 // Plus infinity (double and int)
    00095 #ifndef COIN_DBL_MAX
    00096 #define COIN_DBL_MAX DBL_MAX
    00097 #endif
    00098
    00099 #ifndef COIN_INT_MAX
    00100 #define COIN_INT_MAX (static_cast<int>((~(static_cast<unsigned int>(0))) >> 1))
    00101 #endif
    00102
    00103 #ifndef COIN_INT_MAX_AS_DOUBLE
    00104 #define COIN_INT_MAX_AS_DOUBLE (static_cast<double>((~(static_cast<unsigned int>(0))) >> 1))
    00105 #endif
    00106
    00107 //=============================================================================
    00108
    00109 inline bool CoinFinite(double val)
    00110 {
    00111 #ifdef MY_C_FINITE
    00112   //    return static_cast<bool>(MY_C_FINITE(val));
    00113     return MY_C_FINITE(val)!=0;
    00114 #else
    00115     return val != DBL_MAX && val != -DBL_MAX;
    00116 #endif
    00117 }
    00118
    00119 //=============================================================================
    00120
    00121 inline bool CoinIsnan(double val)
    00122 {
    00123 #ifdef MY_C_ISNAN
    00124   //    return static_cast<bool>(MY_C_ISNAN(val));
    00125     return MY_C_ISNAN(val)!=0;
    00126 #else
    00127     return false;
    00128 #endif
    00129 }
    00130
    00131 //=============================================================================
    00132
    00133 #endif