30 #ifndef _SPXDEFINES_H_ 31 #define _SPXDEFINES_H_ 45 #ifdef SOPLEX_WITH_BOOST 46 #include "boost/multiprecision/number.hpp" 52 bool EQ(
int a,
int b);
54 #define SOPLEX_VERSION 500 55 #define SOPLEX_SUBVERSION 0 56 #define SOPLEX_APIVERSION 11 57 #define SOPLEX_COPYRIGHT "Copyright (c) 1996-2020 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)" 74 #if defined (NDEBUG) && defined (WITH_WARNINGS) 75 #define ASSERT_WARN( prefix, expr ) \ 80 << " failed assertion on line " << __LINE__ \ 81 << " in file " << __FILE__ << ": " \ 85 #else // just a normal assert 86 #define ASSERT_WARN( prefix, expr ) ( assert( expr ) ) 102 #ifdef DISABLE_VERBOSITY 103 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) {} 104 #define DO_WITH_ERR_VERBOSITY( do_something ) {} 106 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) \ 108 if( &spxout != NULL ) \ 110 if( verbosity <= spxout.getVerbosity() ) \ 112 const SPxOut::Verbosity old_verbosity = spxout.getVerbosity(); \ 113 spxout.setVerbosity( verbosity ); \ 115 spxout.setVerbosity( old_verbosity ); \ 119 #define DO_WITH_ERR_VERBOSITY( do_something ) { do_something; } 123 #define MSG_ERROR(x) { DO_WITH_ERR_VERBOSITY( x ) } 125 #define MSG_WARNING(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::WARNING, spxout, x ) } 127 #define MSG_INFO1(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO1, spxout, x ) } 129 #define MSG_INFO2(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO2, spxout, x ) } 131 #define MSG_INFO3(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO3, spxout, x ) } 133 extern bool msginconsistent(
const char* name,
const char* file,
int line);
135 #define MSGinconsistent(name) msginconsistent(name, __FILE__, __LINE__) 137 #if defined(SOPLEX_DEBUG) 139 #define MSG_DEBUG(x) { x; } 150 #if !defined(THREADLOCAL) 151 #if defined(_MSC_VER) && _MSC_VER < 1900 154 #define THREADLOCAL thread_local 164 #ifdef WITH_LONG_DOUBLE 167 typedef long double Real;
171 #define REAL_FORMAT "Lf" 174 #ifndef DEFAULT_BND_VIOL 175 #define DEFAULT_BND_VIOL 1e-12L 178 #ifndef DEFAULT_EPS_ZERO 179 #define DEFAULT_EPS_ZERO 1e-28L 182 #ifndef DEFAULT_EPS_FACTOR 183 #define DEFAULT_EPS_FACTOR 1e-30L 186 #ifndef DEFAULT_EPS_UPDATE 187 #define DEFAULT_EPS_UPDATE 1e-26L 189 #ifndef DEFAULT_EPS_PIVOT 190 #define DEFAULT_EPS_PIVOT 1e-20L 193 #define DEFAULT_INFINITY 1e100L 204 #define REAL_FORMAT "f" 207 #ifndef DEFAULT_BND_VIOL 208 #define DEFAULT_BND_VIOL 1e-1f 211 #ifndef DEFAULT_EPS_ZERO 212 #define DEFAULT_EPS_ZERO 1e-7f 214 #ifndef DEFAULT_EPS_FACTOR 215 #define DEFAULT_EPS_FACTOR 1e-7f 217 #ifndef DEFAULT_EPS_UPDATE 218 #define DEFAULT_EPS_UPDATE 1e-6f 220 #ifndef DEFAULT_EPS_PIVOT 221 #define DEFAULT_EPS_PIVOT 1e-6f 223 #define DEFAULT_INFINITY 1e35f 231 #define REAL_FORMAT "lf" 234 #ifndef DEFAULT_BND_VIOL 235 #define DEFAULT_BND_VIOL 1e-6 238 #ifndef DEFAULT_EPS_ZERO 239 #define DEFAULT_EPS_ZERO 1e-16 241 #ifndef DEFAULT_EPS_FACTOR 242 #define DEFAULT_EPS_FACTOR 1e-20 244 #ifndef DEFAULT_EPS_UPDATE 245 #define DEFAULT_EPS_UPDATE 1e-16 247 #ifndef DEFAULT_EPS_PIVOT 248 #define DEFAULT_EPS_PIVOT 1e-10 250 #define DEFAULT_INFINITY 1e100 252 #endif // !WITH_FLOAT 253 #endif // !WITH_LONG_DOUBLE 255 #define MAXIMUM(x,y) ((x)>(y) ? (x) : (y)) 256 #define MINIMUM(x,y) ((x)<(y) ? (x) : (y)) 258 #define SPX_MAXSTRLEN 1024 316 #ifdef WITH_LONG_DOUBLE 320 return nextafterl(x, y);
327 return nextafter(x, y);
329 return _nextafter(x, y);
350 const Real absa =
spxAbs(a);
351 const Real absb =
spxAbs(b);
353 return absa > absb ? absa : absb;
359 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
378 #if defined(_WIN32) || defined(_WIN64) 379 n = _vsnprintf(t, len, s, ap);
381 n = vsnprintf(t, len, s, ap);
385 if(n < 0 || (
size_t) n >= len)
391 MSG_ERROR(std::cerr <<
"vsnprintf returned " << n <<
" while reading: " << s << std::endl;)
402 #ifdef SOPLEX_WITH_BOOST 404 template <
typename T, boost::multiprecision::expression_
template_option eto>
405 boost::multiprecision::number<T, eto>
spxFrexp(boost::multiprecision::number<T, eto> y,
int* exp)
408 using namespace boost::math::tools;
410 return frexp(y, exp);
414 template <
typename T, boost::multiprecision::expression_
template_option eto>
415 boost::multiprecision::number<T>
spxLdexp(boost::multiprecision::number<T, eto> x,
int exp)
417 return boost::multiprecision::ldexp(x, exp);
421 template <
typename T, boost::multiprecision::expression_
template_option ep>
422 boost::multiprecision::number<T, ep>
spxSqrt(boost::multiprecision::number<T, ep> a)
424 return boost::multiprecision::sqrt(a);
428 template <
typename T, boost::multiprecision::expression_
template_option eto>
429 boost::multiprecision::number<T, eto>
spxNextafter(boost::multiprecision::number<T, eto> x,
430 boost::multiprecision::number<T, eto> y)
433 using namespace boost::math;
446 template <
typename T>
447 boost::multiprecision::number<T>
spxSqrt(boost::multiprecision::number<T> a)
449 return boost::multiprecision::sqrt(a);
453 template <
typename T, boost::multiprecision::expression_
template_option et>
454 inline boost::multiprecision::number<T, et>
maxAbs(
455 boost::multiprecision::number<T, et> a, boost::multiprecision::number<T, et> b)
457 const auto absa =
spxAbs(a);
458 const auto absb =
spxAbs(b);
460 return absa > absb ? absa : absb;
463 template <
typename T, boost::multiprecision::expression_
template_option et>
464 inline boost::multiprecision::number<T, et>
relDiff(boost::multiprecision::number<T, et> a,
465 boost::multiprecision::number<T, et> b)
467 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
474 #include "spxdefines.hpp" 476 #endif // _SPXDEFINES_H_ Rational spxAbs(const Rational &r)
Absolute.
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)
Rational spxLdexp(Rational x, int exp)
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
static THREADLOCAL Real s_epsilon
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
Rational spxFrexp(Rational r, int *d)
Everything should be within this namespace.
Real relDiff(Real a, Real b)
returns (a-b) / max(|a|,|b|,1.0)
Real spxNextafter(Real x, Real y)
static void setEpsilonUpdate(Real eps)
static THREADLOCAL Real s_epsilon_update
epsilon for factorization update
static Real epsilonPivot()
static void setEpsilonFactorization(Real eps)
static Real epsilonFactorization()
static THREADLOCAL Real s_epsilon_factorization
epsilon for factorization
#define THREADLOCAL
SOPLEX_DEBUG.