15 #ifndef polybori_routines_pbori_func_h_
16 #define polybori_routines_pbori_func_h_
29 #ifdef PBORI_HAVE_TR1_UNORDERED_MAP
30 # include <tr1/unordered_map>
32 # ifdef PBORI_HAVE_UNORDERED_MAP
33 # include <unordered_map>
35 # ifdef PBORI_HAVE_HASH_MAP
36 # include <ext/hash_map>
47 template <
class ListType,
class ValueType =
typename ListType::value_type >
52 operator()(ListType theList,
const ValueType& elt)
const {
53 theList.push_back(elt);
60 template <
class RhsType,
class LhsType =
typename RhsType::
idx_type >
64 RhsType operator() (
const RhsType& rhs,
const LhsType& lhs)
const {
65 return (rhs.change(lhs));
72 template <
class RhsType = void,
77 template <
class RhsType,
class LhsType>
81 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
82 return (rhs = rhs.change(lhs));
92 template <
class RhsType,
class LhsType>
93 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
94 return (rhs = rhs.change(lhs));
101 template <
class RhsType,
class LhsType =
typename RhsType::
idx_type>
105 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
107 rhs = rhs.subset1(lhs);
114 template <
class RhsType,
class LhsType>
118 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
119 return (rhs = rhs.subset0(lhs));
124 template <
class RhsType,
127 public std::binary_function<RhsType&, const LhsType&, RhsType&> {
130 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
131 return (rhs = rhs.unite(lhs));
143 template <
unsigned int ITH,
unsigned int NLEN = ITH>
148 template <
unsigned int NLEN>
153 template <
class ValueType>
154 void operator() (
const ValueType&, ...)
const { }
159 template <
unsigned int NLEN>
164 template <
class ValueType>
165 const ValueType& operator() (
const ValueType& value, ...)
const {
170 template <
class ValueType>
171 ValueType& operator() (ValueType& value, ...)
const {
179 template <
unsigned int NLEN>
184 template <
class FirstType,
class ValueType>
186 operator() (
const FirstType&,
const ValueType& value, ...)
const {
191 template <
class FirstType,
class ValueType>
192 ValueType& operator() (
const FirstType&, ValueType& value, ...)
const {
200 template <
unsigned int NLEN>
205 template <
class FirstType,
class SecondType,
class ValueType>
207 operator() (
const FirstType&,
const SecondType&,
208 const ValueType& value, ...)
const {
213 template <
class FirstType,
class SecondType,
class ValueType>
214 ValueType& operator() (
const FirstType&,
const SecondType&,
215 ValueType& value, ...)
const {
244 template <
class Type>
245 const self&
operator=(
const Type&)
const {
return *
this;}
262 template <
class IntType, IntType INTCONST,
class ResultType = IntType>
266 enum { result = INTCONST };
273 template <
class BinaryOp,
class FirstOp,
class SecondOp>
290 base(binop), first_op(unop1), second_op(unop2) {}
296 template <
class FirstType,
class SecondType>
298 const SecondType& second)
const {
299 return base::operator()(first_op(first), second_op(second));
303 template <
class FirstType,
class SecondType>
305 const SecondType& second)
const {
306 return base::operator()(first_op(first), second_op(second));
310 template <
class FirstType,
class SecondType>
312 SecondType& second)
const {
313 return base::operator()(first_op(first), second_op(second));
324 template <
class BinaryOp,
class UnaryOperation>
341 base(binop, unop, unop) {}
346 template<
class ValueType>
352 return max = std::max(max, val);
361 template <
class DDType>
368 #if defined(PBORI_ADD_BY_OR)
369 (lhs = (lhs.diff(rhs)).unite(rhs.diff(lhs)));
371 # elif defined(PBORI_ADD_BY_UNION)
372 (lhs = lhs.unite(rhs).diff( lhs.intersect(rhs) ) );
373 # elif defined(PBORI_ADD_BY_EXTRA_XOR) || defined(PBORI_ADD_BY_XOR)
374 (lhs = lhs.Xor(rhs));
381 template <
class DDType,
class IdxType =
typename DDType::
idx_type>
388 DDType tmp( lhs.subset0(idx) );
403 template <
class DDType,
class IdxType =
typename DDType::
idx_type>
409 lhs = lhs.unite( lhs.change(idx) );
433 template <
class RhsType = void,
437 template <
class RhsType,
class LhsType>
439 public std::binary_function<RhsType&, const LhsType&, RhsType&> {
442 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
451 template <
class RhsType,
class LhsType>
452 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
461 template <
class RhsType = void,
465 template <
class RhsType,
class LhsType>
467 public std::binary_function<RhsType&, const LhsType&, RhsType&> {
470 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
471 rhs.insertAssign(lhs);
479 template <
class RhsType,
class LhsType>
480 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
481 rhs.insertAssign(lhs);
490 template <
class RhsType = void,
495 template <
class RhsType,
class LhsType>
497 public std::binary_function<RhsType&, const LhsType&, RhsType&> {
500 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
511 template <
class RhsType,
class LhsType>
512 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
520 template <
class RhsType = void,
525 template <
class RhsType,
class LhsType>
527 public std::binary_function<RhsType&, const LhsType&, RhsType&> {
530 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
531 rhs.removeAssign(lhs);
541 template <
class RhsType,
class LhsType>
542 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
543 rhs.removeAssign(lhs);
550 template <
class ListType,
class RhsType,
class LhsType>
555 theList(theList__) {};
557 RhsType& operator() (RhsType& rhs,
const LhsType& lhs)
const {
570 template <
class Type1,
class Type2>
573 template <
class Type>
577 template <
class Type1,
class Type2>
581 template <
class Type>
588 template <
class Type1,
class Type2,
class ThenType,
class ElseType>
591 template <
class Type,
class ThenType,
class ElseType>
597 template <
class Type1,
class Type2,
class ThenType,
class ElseType>
615 template <
class Type>
626 template <
class Type>
633 #ifdef PBORI_HAVE_TR1_UNORDERED_MAP
634 typedef std::tr1::unordered_map<Type, idx_type, hashes<Type> >
type;
636 # ifdef PBORI_HAVE_UNORDERED_MAP
637 typedef std::unordered_map<Type, idx_type, hashes<Type> >
type;
639 # ifdef PBORI_HAVE_HASH_MAP
640 typedef __gnu_cxx::hash_map<Type, idx_type, hashes<Type> >
type;
642 typedef std::map<Type, idx_type>
type;
651 template <
class ListType>
653 public std::binary_function<const ListType&, const ListType&, bool> {
656 bool operator()(
const ListType& lhs,
const ListType& rhs)
const {
657 return (lhs.size() < rhs.size());
664 template <
class BiIterator>
676 typedef typename std::iterator_traits<iterator>::difference_type
678 typedef typename std::iterator_traits<iterator>::pointer
pointer;
679 typedef typename std::iterator_traits<iterator>::reference
reference;
680 typedef typename std::iterator_traits<iterator>::value_type
value_type;
706 return m_iter == rhs.m_iter;
710 return m_iter != rhs.m_iter;
721 template <
class DDType>
723 public std::unary_function<DDType, typename DDType::navigator> {
732 typedef std::unary_function<dd_type, navigator>
base;
736 return rhs.navigation();
742 template <
class ValueType>
753 template <
template<
class>
class BindType,
class BinaryFunction,
754 class ValueType,
class ConstantOp>
756 public BindType<BinaryFunction>{
767 template <
class BinaryFunction,
class ConstantOp>
770 typename BinaryFunction::second_argument_type,
775 template <
class BinaryFunction,
class ConstantOp>
778 typename BinaryFunction::first_argument_type,
782 template <
template<
class>
class BindType,
783 class BinaryFunction,
class ValueType>
785 public BindType<BinaryFunction>{
795 template <
class BinaryFunction>
798 typename BinaryFunction::second_argument_type> {
801 typename BinaryFunction::second_argument_type>
808 template <
class BinaryFunction>
811 typename BinaryFunction::first_argument_type> {
832 template <
class ManagerType,
834 class VarNameType =
typename ManagerType::const_varname_reference>
846 return m_mgr.getVariableName(idx);
854 template <
class MapType,
class VariableType,
class TermType,
class NodeType>
866 return ((TermType)VariableType(m_map[idx]))*first + second;
872 const map_type& m_map;
880 template <
class NewType>
885 template <
class DDType>
889 typename DDType::node_type
operator()(
const DDType& rhs)
const {
890 return rhs.getNode();