pbori_defs.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_pbori_defs_h_
#define polybori_pbori_defs_h_
#include <cstddef>
#include <iostream>
#include <polybori/cudd/cudd.h>
#include "config.h"
#ifndef PBORI_UNIQUE_SLOTS
# define PBORI_UNIQUE_SLOTS CUDD_UNIQUE_SLOTS // initial size of subtables
#endif
#ifndef PBORI_CACHE_SLOTS
# define PBORI_CACHE_SLOTS CUDD_CACHE_SLOTS // default size of the cache
#endif
#ifndef PBORI_MAX_MEMORY
# define PBORI_MAX_MEMORY 0 // target maximum memory occupation
// if PBORI_MAX_MEMORY == 0 then
// guess based on the available memory
#endif
#ifdef __GNUC__
#ifndef PBORI_LIKELY
#define PBORI_LIKELY(expression) (__builtin_expect(!!(expression), 1))
#endif
#ifndef PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
#endif
#else
#ifndef PBORI_LIKELY
#define PBORI_LIKELY(expression) (expression)
#endif
#ifndef PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression) (expression)
#endif
#endif
#define PBORINAME polybori
#ifndef PBORI_NO_DEVELOPER
# define PBORI_DEVELOPER
#endif
#ifndef PBORI_NO_NAMESPACES
# define BEGIN_NAMESPACE_PBORI namespace PBORINAME {
# define END_NAMESPACE_PBORI } // end of namespace
# define USING_NAMESPACE_PBORI using namespace PBORINAME;
# define PBORI PBORINAME
# define USING_PBORI using PBORI
# define PBORI_BEGIN_NAMESPACE( sub_space ) namespace sub_space {
# define PBORI_END_NAMESPACE }
#else
# define BEGIN_NAMESPACE_PBORI
# define END_NAMESPACE_PBORI
# define USING_NAMESPACE_PBORI
# define PBORI
# define USING_PBORI
# define PBORI_BEGIN_NAMESPACE( sub_space )
# define PBORI_END_NAMESPACE
#endif // PBORI_NO_NAMESPACES
#ifdef PBORI_DEBUG_TRACE
# include <iostream>
# define PBORI_TRACE_FUNC(text) std::cerr << text << std::endl;
#else
# define PBORI_TRACE_FUNC(text)
#endif
// @todo force assertIon of PBORI_DEBUG
#if defined(PBORI_NDEBUG)
#define PBORI_ASSERT(arg) (static_cast<void>(0))
#else
#define PBORI_ASSERT(arg) assert(arg)
#endif
#ifndef PBORI_NO_STDSTREAMS
# include <iostream>
# define PBORI_OSTREAM std::ostream
#else
BEGIN_NAMESPACE_PBORI
struct PBORI_OSTREAM {};
template <class StreamedType>
PBORI_OSTREAM&
operator<<(PBORI_OSTREAM& dummy, const StreamedType&) {
return dummy;
};
END_NAMESPACE_PBORI
#endif // of #ifndef PBORI_NO_STDSTREAMS
BEGIN_NAMESPACE_PBORI
struct COrderEnums {
enum ordercodes {
lp,
dlex,
dp_asc,
block_dlex,
block_dp_asc
};
};
struct CErrorEnums {
enum errorcodes {
alright = 0,
failed,
no_ring,
invalid,
out_of_bounds,
io_error,
monomial_zero,
illegal_on_zero,
division_by_zero,
invalid_ite,
not_implemented,
matrix_size_exceeded,
last_error
};
};
struct CCompareEnums {
enum comparecodes {
less_than = -1,
equality = 0,
greater_than = +1,
less_or_equal_max = 0,
greater_or_equal_min = 0
};
enum { max_idx = CUDD_MAXINDEX };
};
struct CAuxTypes {
//-------------------------------------------------------------------------
// types for several purposes
//-------------------------------------------------------------------------
typedef bool bool_type;
typedef std::size_t size_type;
typedef int deg_type;
typedef int integer_type;
typedef int idx_type;
typedef std::size_t hash_type;
typedef unsigned int errornum_type;
typedef short int comp_type;
typedef int ordercode_type;
typedef const char* errortext_type;
typedef PBORI_OSTREAM ostream_type;
typedef const char* vartext_type;
typedef unsigned long large_size_type;
typedef std::size_t refcount_type;
};
class BooleSet;
class BoolePolyRing;
struct CTypes:
public COrderEnums, public CErrorEnums, public CCompareEnums,
public CAuxTypes {
//-------------------------------------------------------------------------
// types for treatment of decision diagrams
//-------------------------------------------------------------------------
typedef COrderEnums orderenums_type;
typedef CErrorEnums errorenums_type;
typedef CCompareEnums compenums_type;
typedef CAuxTypes auxtypes_type;
// typedef BooleSet dd_type;
static idx_type max_index() { return max_idx; }
};
END_NAMESPACE_PBORI
#ifdef PBORI_DEVELOPER
# define PBORI_NOT_IMPLEMENTED \
throw PBORI::PBoRiError(PBORI::CTypes::not_implemented);
#else
# define PBORI_NOT_IMPLEMENTED
#endif
// Set default addition method
#if defined(PBORI_ADD_BY_ITE) || defined(PBORI_ADD_BY_OR) \
|| defined(PBORI_ADD_BY_UNION) || defined(PBORI_ADD_BY_EXTRA_XOR) \
|| defined(PBORI_ADD_BY_XOR)
#else
# define PBORI_ADD_BY_XOR
#endif
// Set default union-xor method
#ifdef PBORI_ADD_BY_XOR
# define PBORI_LOWLEVEL_XOR
#endif
// Set default method for getting all used variables
#if defined(PBORI_USEDVARS_BY_IDX) || defined(PBORI_USEDVARS_BY_TRANSFORM) \
|| defined(PBORI_USEDVARS_HIGHLEVEL)|| defined(PBORI_USEDVARS_BY_SUPPORT)\
|| defined(PBORI_USEDVARS_EXTRA)
#else
# define PBORI_USEDVARS_BY_IDX
//PBORI_USEDVARS_EXTRA
#endif
#endif // of #ifndef polybori_pbori_defs_h_