PolyBoRi
pbori_defs.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00017 //*****************************************************************************
00018 
00019 #include <cstddef>
00020 
00021 #include <iostream>
00022 #include "util.h"
00023 #include <cudd.h>
00024 
00025 #include "cacheopts.h"
00026 
00027 #ifndef pbori_defs_h_
00028 #define pbori_defs_h_
00029 
00030 #ifndef PBORI_UNIQUE_SLOTS
00031 #  define PBORI_UNIQUE_SLOTS CUDD_UNIQUE_SLOTS // initial size of subtables
00032 #endif
00033 
00034 #ifndef PBORI_CACHE_SLOTS
00035 #  define PBORI_CACHE_SLOTS CUDD_CACHE_SLOTS   // default size of the cache
00036 #endif
00037 
00038 #ifndef PBORI_MAX_MEMORY
00039 #  define PBORI_MAX_MEMORY 0    // target maximum memory occupation
00040                                 // if PBORI_MAX_MEMORY == 0 then
00041                                 // guess based on the available memory  
00042 #endif
00043 
00044 
00046 #ifdef __GNUC__
00047 #ifndef LIKELY
00048 #define LIKELY(expression) (__builtin_expect(!!(expression), 1))
00049 #endif
00050 #ifndef UNLIKELY
00051 #define UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
00052 #endif
00053 #else
00054 #ifndef LIKELY
00055 #define LIKELY(expression) (expression)
00056 #endif
00057 #ifndef UNLIKELY
00058 #define UNLIKELY(expression) (expression)
00059 #endif
00060 #endif 
00061 
00063 #define PBORINAME polybori
00064 
00066 #ifndef PBORI_NO_DEVELOPER
00067 #  define PBORI_DEVELOPER
00068 #endif
00069 
00070 #ifndef PBORI_NO_NAMESPACES
00071 
00073 #  define BEGIN_NAMESPACE_PBORI namespace PBORINAME {
00074 
00076 #  define END_NAMESPACE_PBORI } // end of namespace 
00077 
00079 #  define USING_NAMESPACE_PBORI using namespace PBORINAME;
00080 
00082 #  define PBORI PBORINAME
00083 
00085 #  define USING_PBORI using PBORI
00086 
00088 #  define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space {
00089 
00091 #  define PBORI_END_NAMESPACE }
00092 
00093 #else 
00094 
00095 #  define BEGIN_NAMESPACE_PBORI 
00096 #  define END_NAMESPACE_PBORI 
00097 #  define USING_NAMESPACE_PBORI 
00098 #  define PBORI 
00099 #  define USING_PBORI 
00100 #  define PBORI_BEGIN_NAMESPACE( sub_space ) 
00101 #  define PBORI_END_NAMESPACE 
00102 
00103 #endif // PBORI_NO_NAMESPACES
00104 
00106 #ifdef PBORI_DEBUG_TRACE
00107 # include <iostream>
00108 # define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl;
00109 #else
00110 # define PBORI_TRACE_FUNC(text) 
00111 #endif
00112 
00114 #ifndef PBORI_NO_STDSTREAMS
00115 
00116 # include <iostream>
00117 # define PBORI_OSTREAM std::ostream
00118 
00119 #else
00120 
00121 BEGIN_NAMESPACE_PBORI
00122 
00124 struct PBORI_OSTREAM {};
00125 
00126 template <class StreamedType>
00127 PBORI_OSTREAM& 
00128 operator<<(PBORI_OSTREAM& dummy, const StreamedType&) {
00129   return dummy;
00130 };
00131 END_NAMESPACE_PBORI
00132 
00133 #endif // of #ifndef PBORI_NO_STDSTREAMS
00134 
00135 
00136 BEGIN_NAMESPACE_PBORI
00137 
00138 
00144 struct COrderEnums {
00146   enum ordercodes {
00147     lp,
00148     dlex,
00149     dp_asc,
00150     block_dlex,
00151     block_dp_asc
00152   };
00153 };
00154 
00160 struct CErrorEnums {
00162   enum errorcodes {
00163     alright = 0,
00164     failed,
00165     no_ring,
00166     invalid,
00167     out_of_bounds,
00168     io_error,
00169     monomial_zero,
00170     illegal_on_zero,
00171     division_by_zero,
00172     invalid_ite,
00173     not_implemented,
00174     matrix_size_exceeded,
00175 
00176     last_error
00177   };
00178 };
00179 
00185 struct CCompareEnums {
00187   enum comparecodes {
00188     less_than = -1,
00189     equality = 0,
00190     greater_than = +1,
00191     less_or_equal_max = 0,
00192     greater_or_equal_min = 0
00193   };
00194 
00195   enum { max_idx = CUDD_MAXINDEX };
00196 };
00197 
00202 struct CAuxTypes {
00203   //-------------------------------------------------------------------------
00204   // types for several purposes
00205   //-------------------------------------------------------------------------
00206 
00208   typedef bool bool_type;
00209 
00211   typedef std::size_t size_type;
00212 
00214   typedef int deg_type;
00215 
00217   typedef int integer_type;
00218 
00220   typedef int idx_type;
00221 
00223   typedef std::size_t hash_type;
00224 
00226   typedef unsigned int errornum_type;
00227 
00229   typedef short int comp_type;
00230 
00232   typedef int ordercode_type;
00233 
00235   typedef const char* errortext_type;
00236 
00238   typedef PBORI_OSTREAM ostream_type;
00239 
00241   typedef const char* vartext_type;
00242 
00244   typedef unsigned long large_size_type;
00245 
00247   typedef std::size_t refcount_type;
00248 };
00249 
00250 class BooleSet;
00251 class BoolePolyRing;
00252 
00261 struct CTypes: 
00262   public COrderEnums, public CErrorEnums, public CCompareEnums,
00263   public CAuxTypes {
00264   //-------------------------------------------------------------------------
00265   // types for treatment of decision diagrams
00266   //-------------------------------------------------------------------------
00267 
00269 
00270   typedef COrderEnums orderenums_type;
00271   typedef CErrorEnums errorenums_type;
00272   typedef CCompareEnums compenums_type;
00273   typedef CAuxTypes auxtypes_type;
00275 
00276 
00278   //  typedef BooleSet dd_type;
00279 
00280 
00282   static idx_type max_index() { return max_idx; }
00283 };
00284 
00285 END_NAMESPACE_PBORI
00286 
00287 #ifdef PBORI_DEVELOPER
00288 # define PBORI_NOT_IMPLEMENTED \
00289   throw PBORI::PBoRiError(PBORI::CTypes::not_implemented);
00290 #else
00291 # define PBORI_NOT_IMPLEMENTED 
00292 #endif
00293 
00294 // Set default addition method
00295 #if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \
00296     || defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \
00297     || defined(PBORI_ADD_BY_XOR)
00298 #else
00299 # define PBORI_ADD_BY_XOR
00300 #endif 
00301 
00302 
00303 // Set default union-xor method
00304 #ifdef PBORI_ADD_BY_XOR
00305 # define PBORI_LOWLEVEL_XOR 
00306 #endif 
00307 
00308 // Set default method for getting all used variables
00309 #if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \
00310   || defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\
00311   || defined(PBORI_USEDVARS_EXTRA)
00312 #else
00313 # define PBORI_USEDVARS_BY_IDX
00314 //PBORI_USEDVARS_EXTRA
00315 #endif 
00316 
00317 
00318 #endif // of #ifndef pbori_defs_h_