COrderingFacade.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_orderings_COrderingFacade_h_
#define polybori_orderings_COrderingFacade_h_
// include basic definitions
#include <polybori/pbori_defs.h>
#include <polybori/BoolePolynomial.h>
#include <polybori/BooleMonomial.h>
#include <polybori/BooleExponent.h>
#include "COrderingBase.h"
#include "COrderingTags.h"
#include <polybori/iterators/COrderedIter.h>
// include ordering tags
#include <polybori/common/tags.h>
#include "order_traits.h"
// include polybori functionals
#include <polybori/routines/pbori_func.h>
BEGIN_NAMESPACE_PBORI
template <class OrderType, class OrderTag>
class COrderingFacade:
public COrderingBase,
public COrderingTags<OrderTag>, public order_traits<OrderTag> {
typedef COrderingFacade self;
typedef COrderingBase base_type;
public:
typedef self base;
typedef OrderType order_type;
typedef CCacheTypes::lead_tag<OrderTag> order_lead_tag;
typedef COrderingTags<OrderTag> ordering_tags;
COrderingFacade():
base_type() { }
COrderingFacade(const self& rhs):
base_type(rhs) { }
~COrderingFacade() { }
poly_type leadFirst(const poly_type& poly) const {
if(orderedStandardIteration())
return poly;
else
return lead(poly);
}
bool_type isLexicographical() const {
return is_valid<typename ordering_tags::lex_property>::result;
}
bool_type orderedStandardIteration() const {
return is_valid<typename ordering_tags::ordered_property>::result;
}
bool_type isSymmetric() const {
return is_valid<typename ordering_tags::symmetry_property>::result;
}
bool_type isDegreeOrder() const {
return is_valid<typename ordering_tags::degorder_property>::result;
}
bool_type isBlockOrder() const {
return is_valid<typename ordering_tags::blockorder_property>::result;
}
bool_type isTotalDegreeOrder() const {
return is_valid<typename ordering_tags::totaldegorder_property>::result;
}
bool_type isDegreeReverseLexicographical() const {
return is_valid<typename ordering_tags::degrevlexorder_property>::result;
}
bool_type ascendingVariables() const {
return is_valid<typename ordering_tags::ascending_property>::result;
}
bool_type descendingVariables() const {
return is_valid<typename ordering_tags::descending_property>::result;
}
ordercode_type getOrderCode() const {
return order_traits<OrderTag>::order_code;
}
ordercode_type getBaseOrderCode() const {
return order_traits<OrderTag>::baseorder_code;
}
bool_type lieInSameBlock(idx_type first, idx_type second) const {
return inSameBlockInternal(first, second,
typename ordering_tags::blockorder_property());
}
idx_type lastBlockStart() const {
if (isBlockOrder()) {
return *(blockEnd() - 2);
}
else if (isLexicographical()) {
return CTypes::max_idx;
}
return 0;
}
// Initialize iterator corresponding to leading term
ordered_iterator
leadIteratorBegin(const poly_type& poly) const {
return CGenericOrderedIter<order_type, navigator,
monom_type>(poly.navigation(), poly.ring());
}
ordered_iterator
leadIteratorEnd(const poly_type& poly) const {
return CGenericOrderedIter<order_type, navigator, monom_type>(navigator(), poly.ring());
}
// Initialize iterator corresponding to leading term
ordered_exp_iterator
leadExpIteratorBegin(const poly_type& poly) const {
return CGenericOrderedIter<order_type, navigator, exp_type>(poly.navigation(), poly.ring());
}
ordered_exp_iterator
leadExpIteratorEnd(const poly_type& poly) const {
return CGenericOrderedIter<order_type, navigator, exp_type>(navigator(), poly.ring());
}
protected:
bool_type inSameBlockInternal(idx_type, idx_type,
invalid_tag) const { // not a block order
return true;
}
bool_type inSameBlockInternal(idx_type first, idx_type second,
valid_tag) const { // is block order
// todo: throw here if first,second >=CTypes::max_idx
if(PBORI_UNLIKELY(first > CTypes::max_idx || second > CTypes::max_idx ||
first < 0 || second < 0))
throw std::runtime_error("Variable index out of range.");
if (second < first)
std::swap(first, second);
block_iterator upper(blockBegin());
while (first >= *upper) // Note: convention, last element is max_idx
++upper;
return (second < *upper);
}
};
END_NAMESPACE_PBORI
#endif
polybori::invalid_tag
This class shows, whether a property of an order is invalid.
Definition: tags.h:27
polybori::COrderingFacade::isTotalDegreeOrder
bool_type isTotalDegreeOrder() const
Test whether we deal with a total degree-ordering.
Definition: COrderingFacade.h:110
polybori::COrderingFacade::leadExpIteratorEnd
ordered_exp_iterator leadExpIteratorEnd(const poly_type &poly) const
End marker for exponent iterator corresponding to leading term.
Definition: COrderingFacade.h:177
polybori::COrderingFacade::lastBlockStart
idx_type lastBlockStart() const
Generic procedure to get index, where last block starts.
Definition: COrderingFacade.h:148
polybori::COrderingFacade::leadIteratorBegin
ordered_iterator leadIteratorBegin(const poly_type &poly) const
Initialize iterator corresponding to leading term.
Definition: COrderingFacade.h:160
polybori::BoolePolynomial::navigation
navigator navigation() const
Navigate through structure.
Definition: BoolePolynomial.h:441
END_NAMESPACE_PBORI
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
polybori::COrderingFacade::lieInSameBlock
bool_type lieInSameBlock(idx_type first, idx_type second) const
Definition: COrderingFacade.h:141
BEGIN_NAMESPACE_PBORI
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
polybori::COrderingFacade::order_type
OrderType order_type
Variable ordering definiton functional type.
Definition: COrderingFacade.h:58
polybori::COrderingFacade
This class initialize the interface for orderings of CDynamicOrderBase for a given OrderType...
Definition: COrderingFacade.h:43
polybori::COrderingFacade::leadFirst
poly_type leadFirst(const poly_type &poly) const
Generates polynomial with leading term first (other terms may be skipped)
Definition: COrderingFacade.h:76
polybori::order_traits
Definition: order_traits.h:41
polybori::COrderingFacade::order_lead_tag
CCacheTypes::lead_tag< OrderTag > order_lead_tag
Tag for for leading monomial cache.
Definition: COrderingFacade.h:61
polybori::COrderingFacade::ascendingVariables
bool_type ascendingVariables() const
Test whether variables are in ascending order.
Definition: COrderingFacade.h:120
polybori::BoolePolynomial::ring
const ring_type & ring() const
Access ring, where this belongs to.
Definition: BoolePolynomial.h:478
polybori::COrderingFacade::ordering_tags
COrderingTags< OrderTag > ordering_tags
Definition: COrderingFacade.h:62
polybori::COrderingFacade::isLexicographical
bool_type isLexicographical() const
Check whether ring is lexicographical.
Definition: COrderingFacade.h:85
polybori::COrderingFacade::base
self base
*this is to be used as base for OrderType only
Definition: COrderingFacade.h:55
polybori::COrderingBase
Definition: COrderingBase.h:43
polybori::COrderingFacade::getOrderCode
ordercode_type getOrderCode() const
Get numerical code for ordering.
Definition: COrderingFacade.h:130
pbori_func.h
COrderedIter.h
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::COrderingFacade::isDegreeReverseLexicographical
bool_type isDegreeReverseLexicographical() const
Test whether ordering is deg-rev-lex ordering.
Definition: COrderingFacade.h:115
order_traits.h
polybori::COrderingFacade::descendingVariables
bool_type descendingVariables() const
Test whether variables are in descending order.
Definition: COrderingFacade.h:125
polybori::COrderingBase::block_iterator
block_idx_type::const_iterator block_iterator
Type for block iterators.
Definition: COrderingBase.h:68
pbori_defs.h
polybori::COrderingFacade::~COrderingFacade
~COrderingFacade()
Destructor.
Definition: COrderingFacade.h:72
polybori::COrderingFacade::isDegreeOrder
bool_type isDegreeOrder() const
Test whether we deal with a degree-ordering.
Definition: COrderingFacade.h:100
polybori::COrderingFacade::COrderingFacade
COrderingFacade(const self &rhs)
Construct new decision diagramm manager.
Definition: COrderingFacade.h:68
COrderingBase.h
polybori::COrderingFacade::isBlockOrder
bool_type isBlockOrder() const
Test whether we deal with a degree-ordering.
Definition: COrderingFacade.h:105
BoolePolynomial.h
polybori::COrderingFacade::orderedStandardIteration
bool_type orderedStandardIteration() const
Test whether iterators respect order.
Definition: COrderingFacade.h:90
polybori::CAuxTypes::idx_type
int idx_type
Type for indices.
Definition: pbori_defs.h:228
BooleMonomial.h
polybori::COrderingTags
This tempalte class is base for classes which define ordering tags and properties.
Definition: COrderingTags.h:69
polybori::COrderingFacade::leadExpIteratorBegin
ordered_exp_iterator leadExpIteratorBegin(const poly_type &poly) const
Initialize exponent iterator corresponding to leading term.
Definition: COrderingFacade.h:172
COrderingTags.h
polybori::COrderingFacade::leadIteratorEnd
ordered_iterator leadIteratorEnd(const poly_type &poly) const
End marker for iterator corresponding to leading term.
Definition: COrderingFacade.h:166
polybori::COrderingFacade::isSymmetric
bool_type isSymmetric() const
Test whether variable pertubation do not change the order.
Definition: COrderingFacade.h:95
tags.h
polybori::COrderingFacade::getBaseOrderCode
ordercode_type getBaseOrderCode() const
Get numerical code for base ordering (the same for non-block orderings)
Definition: COrderingFacade.h:135
polybori::CCuddNavigator
This class defines an iterator for navigating through then and else branches of ZDDs.
Definition: CCuddNavigator.h:36
polybori::COrderingFacade::inSameBlockInternal
bool_type inSameBlockInternal(idx_type, idx_type, invalid_tag) const
trivial case for non-block orderings
Definition: COrderingFacade.h:184
BooleExponent.h
polybori::BooleMonomial
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
polybori::COrderingFacade::inSameBlockInternal
bool_type inSameBlockInternal(idx_type first, idx_type second, valid_tag) const
complicated case for block orderings
Definition: COrderingFacade.h:190
polybori::CAuxTypes::bool_type
bool bool_type
Type for standard true/false statements.
Definition: pbori_defs.h:216
polybori::CCacheTypes::lead_tag
Definition: CCacheManagement.h:41
PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
polybori::CGenericOrderedIter
Definition: COrderedIter.h:203
polybori::valid_tag
This class shows, whether a property of an order is valid.
Definition: tags.h:32
polybori::is_valid
Definition: pbori_func.h:582
polybori::CAuxTypes::ordercode_type
int ordercode_type
Type for ordering codes.
Definition: pbori_defs.h:240
polybori::COrderingFacade::COrderingFacade
COrderingFacade()
Construct new decision diagramm manager.
Definition: COrderingFacade.h:64