30 #ifndef _SPXDEFINES_H_ 31 #define _SPXDEFINES_H_ 48 #ifndef SOPLEX_NO_CONFIG_HEADER 52 #ifdef SOPLEX_WITH_BOOST 53 #include "boost/multiprecision/number.hpp" 54 #ifdef SOPLEX_WITH_FLOAT128 55 #include <boost/multiprecision/float128.hpp> 58 #ifdef SOPLEX_WITH_MPFR 60 #include <boost/multiprecision/mpfr.hpp> 62 #include "boost/multiprecision/debug_adaptor.hpp" 64 #endif // SOPLEX_WITH_MPFR 65 #ifdef SOPLEX_WITH_CPPMPF 66 #include <boost/multiprecision/cpp_dec_float.hpp> 67 #endif // SOPLEX_WITH_CPPMPF 69 #ifdef SOPLEX_WITH_GMP 70 #include <boost/multiprecision/gmp.hpp> 72 #include <boost/multiprecision/cpp_int.hpp> 81 bool EQ(
int a,
int b);
83 #define SOPLEX_VERSION 600 84 #define SOPLEX_SUBVERSION 0 85 #define SOPLEX_APIVERSION 13 86 #define SOPLEX_COPYRIGHT "Copyright (c) 1996-2022 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)" 103 #if defined (NDEBUG) && defined (WITH_WARNINGS) 104 #define ASSERT_WARN( prefix, expr ) \ 109 << " failed assertion on line " << __LINE__ \ 110 << " in file " << __FILE__ << ": " \ 114 #else // just a normal assert 115 #define ASSERT_WARN( prefix, expr ) ( assert( expr ) ) 131 #ifdef DISABLE_VERBOSITY 132 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) {} 133 #define DO_WITH_ERR_VERBOSITY( do_something ) {} 135 #define DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) \ 137 if( &spxout != NULL ) \ 139 if( verbosity <= spxout.getVerbosity() ) \ 141 const SPxOut::Verbosity old_verbosity = spxout.getVerbosity(); \ 142 spxout.setVerbosity( verbosity ); \ 144 spxout.setVerbosity( old_verbosity ); \ 148 #define DO_WITH_ERR_VERBOSITY( do_something ) { do_something; } 152 #define MSG_ERROR(x) { DO_WITH_ERR_VERBOSITY( x ) } 154 #define MSG_WARNING(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::WARNING, spxout, x ) } 156 #define MSG_INFO1(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO1, spxout, x ) } 158 #define MSG_INFO2(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO2, spxout, x ) } 160 #define MSG_INFO3(spxout, x) { DO_WITH_TMP_VERBOSITY( SPxOut::INFO3, spxout, x ) } 162 extern bool msginconsistent(
const char* name,
const char* file,
int line);
164 #define MSGinconsistent(name) msginconsistent(name, __FILE__, __LINE__) 166 #if defined(SOPLEX_DEBUG) 168 #define MSG_DEBUG(x) { x; } 179 #if !defined(THREADLOCAL) 180 #if defined(_MSC_VER) && _MSC_VER < 1900 183 #define THREADLOCAL thread_local 193 #ifdef WITH_LONG_DOUBLE 196 typedef long double Real;
200 #define REAL_FORMAT "Lf" 203 #ifndef DEFAULT_BND_VIOL 204 #define DEFAULT_BND_VIOL 1e-12L 207 #ifndef DEFAULT_EPS_ZERO 208 #define DEFAULT_EPS_ZERO 1e-28L 211 #ifndef DEFAULT_EPS_FACTOR 212 #define DEFAULT_EPS_FACTOR 1e-30L 215 #ifndef DEFAULT_EPS_UPDATE 216 #define DEFAULT_EPS_UPDATE 1e-26L 218 #ifndef DEFAULT_EPS_PIVOT 219 #define DEFAULT_EPS_PIVOT 1e-20L 222 #define DEFAULT_INFINITY 1e100L 233 #define REAL_FORMAT "f" 236 #ifndef DEFAULT_BND_VIOL 237 #define DEFAULT_BND_VIOL 1e-1f 240 #ifndef DEFAULT_EPS_ZERO 241 #define DEFAULT_EPS_ZERO 1e-7f 243 #ifndef DEFAULT_EPS_FACTOR 244 #define DEFAULT_EPS_FACTOR 1e-7f 246 #ifndef DEFAULT_EPS_UPDATE 247 #define DEFAULT_EPS_UPDATE 1e-6f 249 #ifndef DEFAULT_EPS_PIVOT 250 #define DEFAULT_EPS_PIVOT 1e-6f 252 #define DEFAULT_INFINITY 1e35f 260 #define REAL_FORMAT "lf" 263 #ifndef DEFAULT_BND_VIOL 264 #define DEFAULT_BND_VIOL 1e-6 267 #ifndef DEFAULT_EPS_ZERO 268 #define DEFAULT_EPS_ZERO 1e-16 270 #ifndef DEFAULT_EPS_FACTOR 271 #define DEFAULT_EPS_FACTOR 1e-20 273 #ifndef DEFAULT_EPS_UPDATE 274 #define DEFAULT_EPS_UPDATE 1e-16 276 #ifndef DEFAULT_EPS_PIVOT 277 #define DEFAULT_EPS_PIVOT 1e-10 279 #define DEFAULT_INFINITY 1e100 281 #endif // !WITH_FLOAT 282 #endif // !WITH_LONG_DOUBLE 284 #define MAXIMUM(x,y) ((x)>(y) ? (x) : (y)) 285 #define MINIMUM(x,y) ((x)<(y) ? (x) : (y)) 287 #define SPX_MAXSTRLEN 1024 345 #ifdef WITH_LONG_DOUBLE 349 return nextafterl(x, y);
356 return nextafter(x, y);
358 return _nextafter(x, y);
379 const Real absa =
spxAbs(a);
380 const Real absb =
spxAbs(b);
382 return absa > absb ? absa : absb;
388 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
407 #if defined(_WIN32) || defined(_WIN64) 408 n = _vsnprintf(t, len, s, ap);
410 n = vsnprintf(t, len, s, ap);
414 if(n < 0 || (
size_t) n >= len)
420 MSG_ERROR(std::cerr <<
"vsnprintf returned " << n <<
" while reading: " << s << std::endl;)
431 #ifdef SOPLEX_WITH_BOOST 435 #ifdef SOPLEX_WITH_GMP 436 template<boost::multiprecision::expression_
template_option eto>
437 inline number<gmp_rational, eto>
ldexp(number<gmp_rational, eto>,
int exp)
440 return number<gmp_rational>();
443 template<boost::multiprecision::expression_
template_option eto>
444 inline number<gmp_rational, eto>
frexp(number<gmp_rational, eto>,
int* exp)
447 return number<gmp_rational>();
450 inline cpp_rational
ldexp(cpp_rational r,
int exp)
453 return cpp_rational();
456 inline cpp_rational
frexp(cpp_rational,
int* exp)
459 return cpp_rational();
464 template <
typename T, boost::multiprecision::expression_
template_option eto>
465 boost::multiprecision::number<T, eto>
spxFrexp(boost::multiprecision::number<T, eto> y,
int* exp)
467 return frexp(y, exp);
471 template <
typename T, boost::multiprecision::expression_
template_option eto>
472 boost::multiprecision::number<T>
spxLdexp(boost::multiprecision::number<T, eto> x,
int exp)
474 return ldexp(x, exp);
478 template <
typename T, expression_
template_option ep>
485 template <
typename T, expression_
template_option eto>
500 template <
typename T>
507 template <
typename T, expression_
template_option et>
509 number<T, et> a, number<T, et> b)
511 const auto absa =
spxAbs(a);
512 const auto absb =
spxAbs(b);
514 return absa > absb ? absa : absb;
517 template <
typename T, expression_
template_option et>
521 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
529 #include "spxdefines.hpp" 531 #endif // _SPXDEFINES_H_ number< gmp_rational, eto > ldexp(number< gmp_rational, eto >, int exp)
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)
boost::multiprecision::number< T, eto > spxFrexp(boost::multiprecision::number< T, eto > y, 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
number< gmp_rational, eto > frexp(number< gmp_rational, eto >, int *exp)
static Real epsilonUpdate()
Real spxSqrt(Real a)
returns square root
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
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)
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.