00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049  
00050 #ifndef SUTIL_H
00051 #define SUTIL_H 
00052 
00053 
00054 #include <iostream>
00055 #include <cmath>
00056 
00057 #include <LEDA/string.h>
00058 
00059 extern int myInfoFlag;
00060 
00061 #define SPEEDUP false
00062 
00063 #define NODBG false
00064 #define NOINFO false
00065 
00066 #define dbgOn true
00067 
00068 #define DBG \
00069         if( (!NODBG) && dbgOn ) \
00070           std::cerr << "Debug: line " << __LINE__ << " of " << __FILE__ << ": "
00071 
00072 #define DBGX \
00073         if( (!NODBG) && dbgOn ) \
00074           std::cerr
00075 
00076 #define dbgVar(name, val) \
00077         if( (!NODBG) && dbgOn ) \
00078         { \
00079     std::cerr << "Debug: line " << __LINE__ << " of " << __FILE__ << ": " \
00080          << name << " = " << val << std::endl; \
00081   }
00082 
00083 
00084 
00085 
00086 #define infoVar(m, name, val) \
00087         if( (!NOINFO) && (myInfoFlag >= m) ) \
00088         { \
00089       std::cout << name << " = " << val << std::endl; \
00090   }
00091 
00092 inline void die(const leda_string& s)
00093 {
00094   std::cerr << s << std::endl;
00095   exit(1);
00096 }
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 template <class T>
00111 inline T sgn(T x)
00112 {
00113   return (x < 0) ? -1 : ((x == 0) ? 0 : 1);
00114 }
00115 
00116 
00117 inline int min(int a, int b)
00118 {
00119   return (a < b) ? a : b;
00120 }
00121 
00122 inline double min(double a, double b)
00123 {
00124   return (a < b) ? a : b;
00125 }
00126 
00127 #define NOCOPY(classname) \
00128   classname(classname&)
00129 
00130 #define DUMMYIO(classname) \
00131 class foo { \
00132   friend std::ostream& operator<<(std::ostream& os, const foo&) \
00133     { assert( 0 && "Not implemented." ); return os; }; \
00134   friend std::istream& operator>>(std::istream& is, foo&) \
00135     { assert( 0 && "Not implemented." ); return is; }; \
00136 }
00137 
00138 #endif