PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00017 //***************************************************************************** 00018 00019 #ifndef polybori_pbori_defs_h_ 00020 #define polybori_pbori_defs_h_ 00021 00022 #include <cstddef> 00023 00024 #include <iostream> 00025 00027 #include <polybori/cudd/cudd.h> 00028 00029 #include "config.h" 00030 00031 #ifndef PBORI_UNIQUE_SLOTS 00032 # define PBORI_UNIQUE_SLOTS CUDD_UNIQUE_SLOTS // initial size of subtables 00033 #endif 00034 00035 #ifndef PBORI_CACHE_SLOTS 00036 # define PBORI_CACHE_SLOTS CUDD_CACHE_SLOTS // default size of the cache 00037 #endif 00038 00039 #ifndef PBORI_MAX_MEMORY 00040 # define PBORI_MAX_MEMORY 0 // target maximum memory occupation 00041 // if PBORI_MAX_MEMORY == 0 then 00042 // guess based on the available memory 00043 #endif 00044 00045 00047 #ifdef __GNUC__ 00048 #ifndef PBORI_LIKELY 00049 #define PBORI_LIKELY(expression) (__builtin_expect(!!(expression), 1)) 00050 #endif 00051 #ifndef PBORI_UNLIKELY 00052 #define PBORI_UNLIKELY(expression) (__builtin_expect(!!(expression), 0)) 00053 #endif 00054 #else 00055 #ifndef PBORI_LIKELY 00056 #define PBORI_LIKELY(expression) (expression) 00057 #endif 00058 #ifndef PBORI_UNLIKELY 00059 #define PBORI_UNLIKELY(expression) (expression) 00060 #endif 00061 #endif 00062 00064 #define PBORINAME polybori 00065 00067 #ifndef PBORI_NO_DEVELOPER 00068 # define PBORI_DEVELOPER 00069 #endif 00070 00071 #ifndef PBORI_NO_NAMESPACES 00072 00074 # define BEGIN_NAMESPACE_PBORI namespace PBORINAME { 00075 00077 # define END_NAMESPACE_PBORI } // end of namespace 00078 00080 # define USING_NAMESPACE_PBORI using namespace PBORINAME; 00081 00083 # define PBORI PBORINAME 00084 00086 # define USING_PBORI using PBORI 00087 00089 # define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space { 00090 00092 # define PBORI_END_NAMESPACE } 00093 00094 #else 00095 00096 # define BEGIN_NAMESPACE_PBORI 00097 # define END_NAMESPACE_PBORI 00098 # define USING_NAMESPACE_PBORI 00099 # define PBORI 00100 # define USING_PBORI 00101 # define PBORI_BEGIN_NAMESPACE( sub_space ) 00102 # define PBORI_END_NAMESPACE 00103 00104 #endif // PBORI_NO_NAMESPACES 00105 00107 #ifdef PBORI_DEBUG_TRACE 00108 # include <iostream> 00109 # define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl; 00110 #else 00111 # define PBORI_TRACE_FUNC(text) 00112 #endif 00113 00114 // @todo force assertIon of PBORI_DEBUG 00115 #if defined(PBORI_NDEBUG) 00116 #define PBORI_ASSERT(arg) (static_cast<void>(0)) 00117 #else 00118 #define PBORI_ASSERT(arg) assert(arg) 00119 #endif 00120 00122 #ifndef PBORI_NO_STDSTREAMS 00123 00124 # include <iostream> 00125 # define PBORI_OSTREAM std::ostream 00126 00127 #else 00128 00129 BEGIN_NAMESPACE_PBORI 00130 00132 struct PBORI_OSTREAM {}; 00133 00134 template <class StreamedType> 00135 PBORI_OSTREAM& 00136 operator<<(PBORI_OSTREAM& dummy, const StreamedType&) { 00137 return dummy; 00138 }; 00139 END_NAMESPACE_PBORI 00140 00141 #endif // of #ifndef PBORI_NO_STDSTREAMS 00142 00143 00144 BEGIN_NAMESPACE_PBORI 00145 00146 00152 struct COrderEnums { 00154 enum ordercodes { 00155 lp, 00156 dlex, 00157 dp_asc, 00158 block_dlex, 00159 block_dp_asc 00160 }; 00161 }; 00162 00168 struct CErrorEnums { 00170 enum errorcodes { 00171 alright = 0, 00172 failed, 00173 no_ring, 00174 invalid, 00175 out_of_bounds, 00176 io_error, 00177 monomial_zero, 00178 illegal_on_zero, 00179 division_by_zero, 00180 invalid_ite, 00181 not_implemented, 00182 matrix_size_exceeded, 00183 00184 last_error 00185 }; 00186 }; 00187 00193 struct CCompareEnums { 00195 enum comparecodes { 00196 less_than = -1, 00197 equality = 0, 00198 greater_than = +1, 00199 less_or_equal_max = 0, 00200 greater_or_equal_min = 0 00201 }; 00202 00203 enum { max_idx = CUDD_MAXINDEX }; 00204 }; 00205 00210 struct CAuxTypes { 00211 //------------------------------------------------------------------------- 00212 // types for several purposes 00213 //------------------------------------------------------------------------- 00214 00216 typedef bool bool_type; 00217 00219 typedef std::size_t size_type; 00220 00222 typedef int deg_type; 00223 00225 typedef int integer_type; 00226 00228 typedef int idx_type; 00229 00231 typedef std::size_t hash_type; 00232 00234 typedef unsigned int errornum_type; 00235 00237 typedef short int comp_type; 00238 00240 typedef int ordercode_type; 00241 00243 typedef const char* errortext_type; 00244 00246 typedef PBORI_OSTREAM ostream_type; 00247 00249 typedef const char* vartext_type; 00250 00252 typedef unsigned long large_size_type; 00253 00255 typedef std::size_t refcount_type; 00256 }; 00257 00258 class BooleSet; 00259 class BoolePolyRing; 00260 00269 struct CTypes: 00270 public COrderEnums, public CErrorEnums, public CCompareEnums, 00271 public CAuxTypes { 00272 //------------------------------------------------------------------------- 00273 // types for treatment of decision diagrams 00274 //------------------------------------------------------------------------- 00275 00277 00278 typedef COrderEnums orderenums_type; 00279 typedef CErrorEnums errorenums_type; 00280 typedef CCompareEnums compenums_type; 00281 typedef CAuxTypes auxtypes_type; 00283 00284 00286 // typedef BooleSet dd_type; 00287 00288 00290 static idx_type max_index() { return max_idx; } 00291 }; 00292 00293 END_NAMESPACE_PBORI 00294 00295 #ifdef PBORI_DEVELOPER 00296 # define PBORI_NOT_IMPLEMENTED \ 00297 throw PBORI::PBoRiError(PBORI::CTypes::not_implemented); 00298 #else 00299 # define PBORI_NOT_IMPLEMENTED 00300 #endif 00301 00302 // Set default addition method 00303 #if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \ 00304 || defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \ 00305 || defined(PBORI_ADD_BY_XOR) 00306 #else 00307 # define PBORI_ADD_BY_XOR 00308 #endif 00309 00310 00311 // Set default union-xor method 00312 #ifdef PBORI_ADD_BY_XOR 00313 # define PBORI_LOWLEVEL_XOR 00314 #endif 00315 00316 // Set default method for getting all used variables 00317 #if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \ 00318 || defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\ 00319 || defined(PBORI_USEDVARS_EXTRA) 00320 #else 00321 # define PBORI_USEDVARS_BY_IDX 00322 //PBORI_USEDVARS_EXTRA 00323 #endif 00324 00325 00326 #endif // of #ifndef polybori_pbori_defs_h_