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>
288 const first_op_type& unop1 = first_op_type(),
289 const second_op_type& unop2 = second_op_type() ):
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>
340 const unary_op_type& unop = unary_op_type() ):
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>
621 hash_type operator() (
const Type& rhs)
const{
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;
712 iterator
get()
const {
721 template <
class DDType>
723 public std::unary_function<DDType, typename DDType::navigator> {
732 typedef std::unary_function<dd_type, navigator>
base;
735 typename base::result_type
operator()(
const dd_type& rhs)
const{
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>
865 const node_type& first,
const node_type& second)
const{
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();
BinaryOp binary_op_type
Define types corresponding to template arguments.
Definition: pbori_func.h:332
base::result_type result_type
Getting inherited types.
Definition: pbori_func.h:293
const manager_type & m_mgr
Store reference to manager.
Definition: pbori_func.h:851
DDType::node_type operator()(const DDType &rhs) const
Definition: pbori_func.h:889
NodeType node_type
Definition: pbori_func.h:858
const self & operator++(int) const
Definition: pbori_func.h:249
Defines addition operation with assignment for decision diagrams.
Definition: pbori_func.h:362
default_binder_base< std::binder2nd, BinaryFunction, typename BinaryFunction::second_argument_type > base
Definition: pbori_func.h:802
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
result_type operator()(FirstType &first, const SecondType &second) const
The composed operation for constant second argument.
Definition: pbori_func.h:304
VarNameType varname_type
Definition: pbori_func.h:839
binary_composition< binary_op_type, unary_op_type, unary_op_type > base
Definition: pbori_func.h:335
Type::hash_type hash_type
Definition: pbori_func.h:619
Definition: pbori_func.h:665
IdxType idx_type
Definition: pbori_func.h:838
An iterator which virtually does nothing.
Definition: pbori_func.h:238
Accessing .insertAssign()
Definition: pbori_func.h:463
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
Definition: pbori_func.h:616
insert_second_to_list(ListType &theList__)
Definition: pbori_func.h:554
Accessing .remove()
Definition: pbori_func.h:492
BinaryOp base
Define types corresponding to template arguments.
Definition: pbori_func.h:281
This class contains property definitions to be used in polybori classes.
Definition: traits.h:41
value_type operator()(...) const
Definition: pbori_func.h:747
This class tests whether two types equal.
Definition: pbori_func.h:571
binary_composition(const base &binop=base(), const first_op_type &unop1=first_op_type(), const second_op_type &unop2=second_op_type())
Definition: pbori_func.h:287
Accessing .insert()
Definition: pbori_func.h:435
This class switches betweem two types, depending on equality of types.
Definition: pbori_func.h:589
BindType< bin_op > base
Definition: pbori_func.h:788
std::iterator_traits< iterator >::reference reference
Definition: pbori_func.h:679
Accessing ith of n arguments (ITH = 0 returns default value of first type)
Definition: pbori_func.h:144
const self & operator*() const
Definition: pbori_func.h:247
ValueType value_type
Definition: pbori_func.h:790
Accessing .push_back()
Definition: pbori_func.h:48
MapType map_type
Definition: pbori_func.h:857
node_type::idx_type idx_type
Definition: pbori_func.h:860
symmetric_composition(const binary_op_type &binop=binary_op_type(), const unary_op_type &unop=unary_op_type())
Definition: pbori_func.h:339
Definition: pbori_func.h:722
integral_constant()() returns NUM of int_type, instead of possibly arguments...
Definition: pbori_func.h:263
Returns maximun of given argument and previous calls.
Definition: pbori_func.h:347
BinaryFunction bin_op
Definition: pbori_func.h:758
ResultType result_type
Definition: pbori_func.h:265
Accessing .uniteAssign()
Definition: pbori_func.h:126
const self & operator++() const
Definition: pbori_func.h:248
reversed_iteration_adaptor(const iterator &iter)
Constructor.
Definition: pbori_func.h:684
second_op_type second_op
Definition: pbori_func.h:318
This class marks a given type.
Definition: pbori_func.h:613
Definition: pbori_func.h:881
maximum_iteration(ValueType &init)
Definition: pbori_func.h:349
constant_binder_base(const bin_op &op=bin_op())
Definition: pbori_func.h:764
Definition: pbori_func.h:743
first_op_type first_op
Definition: pbori_func.h:317
mapped_new_node(const map_type &the_map)
Definition: pbori_func.h:862
BindType< bin_op > base
Definition: pbori_func.h:760
std::bidirectional_iterator_tag iterator_category
Definition: pbori_func.h:675
base::result_type operator()(const dd_type &rhs) const
The actual operation.
Definition: pbori_func.h:735
Definition: pbori_func.h:627
bool operator!=(const self &rhs) const
Definition: pbori_func.h:709
iterator m_iter
Definition: pbori_func.h:717
std::unary_function< dd_type, navigator > base
Generic access to base type.
Definition: pbori_func.h:732
Accessing .removeAssign()
Definition: pbori_func.h:522
std::iterator_traits< iterator >::pointer pointer
Definition: pbori_func.h:678
result_type operator()(const FirstType &first, const SecondType &second) const
The composed operation for constant arguments.
Definition: pbori_func.h:297
Definition: pbori_func.h:886
Compose a binary function with a default constructable unary function for both arguments.
Definition: pbori_func.h:325
variable_name(const manager_type &mgr)
Constructor.
Definition: pbori_func.h:842
DDType & operator()(DDType &lhs, const DDType &rhs) const
Definition: pbori_func.h:365
BinaryFunction bin_op
Definition: pbori_func.h:787
Accessing .changeAssign()
Definition: pbori_func.h:74
ElseType type
Definition: pbori_func.h:600
const self & operator=(const Type &) const
Definition: pbori_func.h:245
Defines multiplication (with assignment) with the idx-th variable.
Definition: pbori_func.h:404
std::iterator_traits< iterator >::value_type value_type
Definition: pbori_func.h:680
ValueType value_type
Definition: pbori_func.h:762
reference operator*() const
Dereferecing operation.
Definition: pbori_func.h:689
Definition: pbori_func.h:809
Compose a binary function with two default constructable unary functions.
Definition: pbori_func.h:274
std::map< Type, idx_type > type
Type for index maps.
Definition: pbori_func.h:642
default_binder2nd(const typename base::value_type &val)
Definition: pbori_func.h:804
Definition: pbori_func.h:855
self & operator++()
Prefix increment operator.
Definition: pbori_func.h:694
SecondOp second_op_type
Definition: pbori_func.h:283
DDType::navigator navigator
Type for navigation through diagram.
Definition: pbori_func.h:729
ValueType & operator()(const ValueType &val) const
Definition: pbori_func.h:351
Definition: pbori_func.h:768
This class marks an internal part of a procedure.
Definition: pbori_func.h:607
A functional for size comparisons.
Definition: pbori_func.h:652
ValueType value_type
Definition: pbori_func.h:745
Insert second argument to a given list.
Definition: pbori_func.h:551
DDType & operator()(DDType &lhs, IdxType idx) const
Definition: pbori_func.h:407
FirstOp first_op_type
Definition: pbori_func.h:282
Defines multiplication operation with the idx-th variable.
Definition: pbori_func.h:382
Definition: pbori_func.h:784
bool operator()(const ListType &lhs, const ListType &rhs) const
Definition: pbori_func.h:656
BiIterator iterator
The iterator type to be reversed.
Definition: pbori_func.h:669
Definition: pbori_func.h:61
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
ManagerType manager_type
Definition: pbori_func.h:837
Definition: pbori_func.h:776
std::iterator_traits< iterator >::difference_type difference_type
Definition: pbori_func.h:677
self & operator--()
Prefix decrement operator.
Definition: pbori_func.h:700
ListType operator()(ListType theList, const ValueType &elt) const
Definition: pbori_func.h:52
ThenType type
Definition: pbori_func.h:594
result_type operator()(...) const
Definition: pbori_func.h:267
Definition: pbori_func.h:755
UnaryOperation unary_op_type
Definition: pbori_func.h:333
varname_type operator()(idx_type idx) const
Funtional operator.
Definition: pbori_func.h:845
This struct contains type definitions to be used in library classes.
Definition: pbori_defs.h:269
Accessing .subset1Assign()
Definition: pbori_func.h:115
Accessing .subset1Assign()
Definition: pbori_func.h:102
bool operator==(const self &rhs) const
Definition: pbori_func.h:705
DDType dd_type
Type of decision diagram.
Definition: pbori_func.h:726
ConstantOp const_type
Definition: pbori_func.h:759
result_type operator()(const FirstType &first, SecondType &second) const
The composed operation for constant first argument.
Definition: pbori_func.h:311
Definition: pbori_func.h:582
Definition: pbori_func.h:796
DDType & operator()(DDType &lhs, IdxType idx) const
Definition: pbori_func.h:385
Defines generic access to variable names.
Definition: pbori_func.h:835
default_binder_base(const value_type &val)
Definition: pbori_func.h:792
NodeType operator()(idx_type idx, const node_type &first, const node_type &second) const
Definition: pbori_func.h:864