30 #ifndef _SPXDEFINES_H_ 31 #define _SPXDEFINES_H_ 45 #define SOPLEX_VERSION 401 46 #define SOPLEX_SUBVERSION 0 47 #define SOPLEX_APIVERSION 6 48 #define SOPLEX_COPYRIGHT "Copyright (c) 1996-2019 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)" 65 #if defined (NDEBUG) && defined (WITH_WARNINGS) 66 #define ASSERT_WARN( prefix, expr ) \ 71 << " failed assertion on line " << __LINE__ \ 72 << " in file " << __FILE__ << ": " \ 76 #else // just a normal assert 77 #define ASSERT_WARN( prefix, expr ) ( assert( expr ) ) 93 #ifdef DISABLE_VERBOSITY 94 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) {} 95 #define DO_WITH_ERR_VERBOSITY( do_something ) {} 97 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) \ 99 if( &spxout != NULL ) \ 101 if( verbosity <= spxout.getVerbosity() ) \ 103 const SPxOut::Verbosity old_verbosity = spxout.getVerbosity(); \ 104 spxout.setVerbosity( verbosity ); \ 106 spxout.setVerbosity( old_verbosity ); \ 110 #define DO_WITH_ERR_VERBOSITY( do_something ) { do_something; } 114 #define MSG_ERROR(x) { DO_WITH_ERR_VERBOSITY( x ) } 116 #define MSG_WARNING(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::WARNING, spxout, x ) } 118 #define MSG_INFO1(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO1, spxout, x ) } 120 #define MSG_INFO2(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO2, spxout, x ) } 122 #define MSG_INFO3(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO3, spxout, x ) } 124 extern bool msginconsistent(
const char* name,
const char* file,
int line);
126 #define MSGinconsistent(name) msginconsistent(name, __FILE__, __LINE__) 128 #if defined(SOPLEX_DEBUG) 130 #define MSG_DEBUG(x) { x; } 141 #if !defined(THREADLOCAL) 142 #if defined(_MSC_VER) && _MSC_VER < 1900 145 #define THREADLOCAL thread_local 154 #ifdef WITH_LONG_DOUBLE 157 typedef long double Real;
161 #define REAL_FORMAT "Lf" 164 #ifndef DEFAULT_BND_VIOL 165 #define DEFAULT_BND_VIOL 1e-12L 168 #ifndef DEFAULT_EPS_ZERO 169 #define DEFAULT_EPS_ZERO 1e-28L 172 #ifndef DEFAULT_EPS_FACTOR 173 #define DEFAULT_EPS_FACTOR 1e-30L 176 #ifndef DEFAULT_EPS_UPDATE 177 #define DEFAULT_EPS_UPDATE 1e-26L 179 #ifndef DEFAULT_EPS_PIVOT 180 #define DEFAULT_EPS_PIVOT 1e-20L 183 #define DEFAULT_INFINITY 1e100L 194 #define REAL_FORMAT "f" 197 #ifndef DEFAULT_BND_VIOL 198 #define DEFAULT_BND_VIOL 1e-1 201 #ifndef DEFAULT_EPS_ZERO 202 #define DEFAULT_EPS_ZERO 1e-7 204 #ifndef DEFAULT_EPS_FACTOR 205 #define DEFAULT_EPS_FACTOR 1e-7 207 #ifndef DEFAULT_EPS_UPDATE 208 #define DEFAULT_EPS_UPDATE 1e-6 210 #ifndef DEFAULT_EPS_PIVOT 211 #define DEFAULT_EPS_PIVOT 1e-6 213 #define DEFAULT_INFINITY 1e100 222 #define REAL_FORMAT "lf" 225 #ifndef DEFAULT_BND_VIOL 226 #define DEFAULT_BND_VIOL 1e-6 229 #ifndef DEFAULT_EPS_ZERO 230 #define DEFAULT_EPS_ZERO 1e-16 232 #ifndef DEFAULT_EPS_FACTOR 233 #define DEFAULT_EPS_FACTOR 1e-20 235 #ifndef DEFAULT_EPS_UPDATE 236 #define DEFAULT_EPS_UPDATE 1e-16 238 #ifndef DEFAULT_EPS_PIVOT 239 #define DEFAULT_EPS_PIVOT 1e-10 241 #define DEFAULT_INFINITY 1e100 243 #endif // !WITH_FLOAT 244 #endif // !WITH_LONG_DOUBLE 246 #define MAXIMUM(x,y) ((x)>(y) ? (x) : (y)) 247 #define MINIMUM(x,y) ((x)<(y) ? (x) : (y)) 249 #define SPX_MAXSTRLEN 1024 294 #ifdef WITH_LONG_DOUBLE 296 inline Real
spxAbs(Real a)
310 return nextafterl(x, y);
314 inline Real
spxLdexp(Real x,
int exp)
316 return ldexpl(x, exp);
320 inline Real
spxFrexp(Real y,
int* exp)
322 return frexpl(y, exp);
341 return nextafter(x, y);
343 return _nextafter(x, y);
350 return ldexp(x, exp);
356 return frexp(y, exp);
363 const Real absa =
spxAbs(a);
364 const Real absb =
spxAbs(b);
366 return absa > absb ? absa : absb;
372 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
378 return spxAbs(a - b) <= eps;
384 return spxAbs(a - b) > eps;
390 return (a - b) < -eps;
396 return (a - b) < eps;
402 return (a - b) > eps;
408 return (a - b) > -eps;
475 #if defined(_WIN32) || defined(_WIN64) 476 n = _vsnprintf(t, len, s, ap);
478 n = vsnprintf(t, len, s, ap);
482 if(n < 0 || (
size_t) n >= len)
488 MSG_ERROR(std::cerr <<
"vsnprintf returned " << n <<
" while reading: " << s << std::endl;)
500 #endif // _SPXDEFINES_H_ Rational spxAbs(const Rational &r)
Absolute.
bool isNotZero(Real a, Real eps=Param::epsilon())
returns true iff |a| > eps
bool LTrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff relDiff(a,b) <= -eps
bool GE(Real a, Real b, Real eps=Param::epsilon())
returns true iff a >= b + eps
static void setEpsilon(Real eps)
THREADLOCAL const Real infinity
Real maxAbs(Real a, Real b)
returns max(|a|,|b|)
bool msginconsistent(const char *name, const char *file, int line)
bool LE(Real a, Real b, Real eps=Param::epsilon())
returns true iff a <= b + eps
bool LT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a < b + eps
bool NE(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| > eps
Real spxFrexp(Real y, int *exp)
Real spxLdexp(Real x, int exp)
returns x * 2^exp
bool GT(Real a, Real b, Real eps=Param::epsilon())
returns true iff a > b + eps
static void setEpsilonPivot(Real eps)
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
static THREADLOCAL Real s_epsilon_pivot
epsilon for pivot zero tolerance in factorization
static Real epsilonUpdate()
Real spxSqrt(Real a)
returns square root
bool GTrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff relDiff(a,b) > eps
bool GErel(Real a, Real b, Real eps=Param::epsilon())
returns true iff relDiff(a,b) > -eps
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
static THREADLOCAL Real s_epsilon
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Everything should be within this namespace.
Real relDiff(Real a, Real b)
returns (a-b) / max(|a|,|b|,1.0)
bool EQrel(Real a, Real b, Real eps=Param::epsilon())
returns true iff |relDiff(a,b)| <= eps
Real spxNextafter(Real x, Real y)
static void setEpsilonUpdate(Real eps)
bool NErel(Real a, Real b, Real eps=Param::epsilon())
returns true iff |relDiff(a,b)| > eps
static THREADLOCAL Real s_epsilon_update
epsilon for factorization update
static Real epsilonPivot()
bool LErel(Real a, Real b, Real eps=Param::epsilon())
returns true iff relDiff(a,b) <= eps
static void setEpsilonFactorization(Real eps)
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
static Real epsilonFactorization()
static THREADLOCAL Real s_epsilon_factorization
epsilon for factorization
#define THREADLOCAL
SOPLEX_DEBUG.