Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
opt
build
coinutils
coinutils-2.6.4
CoinUtils
src
CoinFinite.hpp
Go to the documentation of this file.
1
/* $Id: CoinFinite.hpp 1215 2009-11-05 11:03:04Z forrest $ */
2
// Copyright (C) 2002, International Business Machines
3
// Corporation and others. All Rights Reserved.
4
5
// Also put all base defines here e.g. VC++ pragmas
6
#ifndef CoinFinite_H
7
#define CoinFinite_H
8
9
#include "
CoinUtilsConfig.h
"
10
11
#include <cstdlib>
12
#ifdef HAVE_CMATH
13
# include <cmath>
14
#else
15
# ifdef HAVE_MATH_H
16
# include <math.h>
17
# else
18
# error "don't have header file for math"
19
# endif
20
#endif
21
22
#ifdef HAVE_CFLOAT
23
# include <cfloat>
24
#else
25
# ifdef HAVE_FLOAT_H
26
# include <float.h>
27
# endif
28
#endif
29
30
#ifdef HAVE_CIEEEFP
31
# include <cieeefp>
32
#else
33
# ifdef HAVE_IEEEFP_H
34
# include <ieeefp.h>
35
# endif
36
#endif
37
38
#include <algorithm>
39
40
//=============================================================================
41
// Compilers can produce better code if they know about __restrict
42
#ifdef COIN_USE_RESTRICT
43
#define COIN_RESTRICT __restrict
44
#else
45
#define COIN_RESTRICT
46
#endif
47
//=============================================================================
48
// Switch on certain things if COIN_FAST_CODE
49
#ifdef COIN_FAST_CODE
50
#ifndef COIN_NOTEST_DUPLICATE
51
#define COIN_NOTEST_DUPLICATE
52
#endif
53
#ifndef COIN_USE_EKK_SORT
54
#define COIN_USE_EKK_SORT
55
#endif
56
#endif
57
//=============================================================================
58
#if COIN_BIG_INDEX==0
59
typedef
int
CoinBigIndex
;
60
#elif COIN_BIG_INDEX==1
61
typedef
long
CoinBigIndex
;
62
#else
63
typedef
long
long
CoinBigIndex
;
64
#endif
65
66
//=============================================================================
67
#ifndef COIN_BIG_DOUBLE
68
#define COIN_BIG_DOUBLE 0
69
#endif
70
// See if we want the ability to have long double work arrays
71
#if COIN_BIG_DOUBLE==2
72
#undef COIN_BIG_DOUBLE
73
#define COIN_BIG_DOUBLE 0
74
#define COIN_LONG_WORK 1
75
typedef
long
double
CoinWorkDouble
;
76
#elif COIN_BIG_DOUBLE==3
77
#undef COIN_BIG_DOUBLE
78
#define COIN_BIG_DOUBLE 1
79
#define COIN_LONG_WORK 1
80
typedef
long
double
CoinWorkDouble
;
81
#else
82
#define COIN_LONG_WORK 0
83
typedef
double
CoinWorkDouble
;
84
#endif
85
#if COIN_BIG_DOUBLE==0
86
typedef
double
CoinFactorizationDouble
;
87
#elif COIN_BIG_DOUBLE==1
88
typedef
long
double
CoinFactorizationDouble
;
89
#else
90
typedef
double
CoinFactorizationDouble
;
91
#endif
92
93
//=============================================================================
94
// Plus infinity (double and int)
95
#ifndef COIN_DBL_MAX
96
#define COIN_DBL_MAX DBL_MAX
97
#endif
98
99
#ifndef COIN_INT_MAX
100
#define COIN_INT_MAX (static_cast<int>((~(static_cast<unsigned int>(0))) >> 1))
101
#endif
102
103
#ifndef COIN_INT_MAX_AS_DOUBLE
104
#define COIN_INT_MAX_AS_DOUBLE (static_cast<double>((~(static_cast<unsigned int>(0))) >> 1))
105
#endif
106
107
//=============================================================================
108
109
inline
bool
CoinFinite
(
double
val)
110
{
111
#ifdef MY_C_FINITE
112
// return static_cast<bool>(MY_C_FINITE(val));
113
return
MY_C_FINITE
(val)!=0;
114
#else
115
return
val != DBL_MAX && val != -DBL_MAX;
116
#endif
117
}
118
119
//=============================================================================
120
121
inline
bool
CoinIsnan
(
double
val)
122
{
123
#ifdef MY_C_ISNAN
124
// return static_cast<bool>(MY_C_ISNAN(val));
125
return
MY_C_ISNAN
(val)!=0;
126
#else
127
return
false
;
128
#endif
129
}
130
131
//=============================================================================
132
133
#endif
Generated on Tue Mar 1 2016 22:31:56 by
1.8.4