PolyBoRi
COrderingBase.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 #ifndef polybori_orderings_COrderingBase_h_
00017 #define polybori_orderings_COrderingBase_h_
00018 
00019 // include basic definitions
00020 #include <polybori/pbori_defs.h>
00021 
00022 #include <polybori/BoolePolynomial.h>
00023 #include <polybori/BooleMonomial.h>
00024 #include <polybori/BooleExponent.h>
00025 #include <polybori/iterators/COrderedIter.h>
00026 #include <polybori/except/PBoRiError.h>
00027 #include <polybori/common/CCheckedIdx.h>
00028 
00029 #include <vector>
00030 
00031 BEGIN_NAMESPACE_PBORI
00032 
00033 class BoolePolynomial;
00034 class BooleMonomial;
00035 class BooleExponent;
00036 class CCuddNavigator;
00037 
00043 class COrderingBase:
00044   public CTypes::auxtypes_type { 
00045 
00047   typedef COrderingBase self;
00048 
00049 public:
00051 
00052   typedef BoolePolynomial poly_type;
00053   typedef BooleMonomial monom_type;
00054   typedef CCuddNavigator navigator;
00055   typedef BooleExponent exp_type;
00056 
00057   typedef COrderedIter<navigator, monom_type> ordered_iterator;
00058   typedef COrderedIter<navigator, exp_type> ordered_exp_iterator;
00060 
00062   typedef CCheckedIdx checked_idx_type;
00063 
00065   typedef std::vector<idx_type> block_idx_type;
00066 
00068   typedef block_idx_type::const_iterator block_iterator;
00069 
00071   typedef BooleSet set_type;
00072 
00074   COrderingBase() { }
00075 
00076   // Destructor
00077   virtual ~COrderingBase() = 0;
00078 
00080   virtual comp_type compare(idx_type, idx_type) const = 0;
00081 
00082   virtual comp_type compare(const monom_type&, const monom_type&) const = 0;
00083 
00084   virtual comp_type compare(const exp_type&, const exp_type&) const = 0;
00085 
00087   virtual monom_type lead(const poly_type&) const = 0;
00088 
00090   virtual monom_type lead(const poly_type&, deg_type) const = 0;
00091 
00093   virtual exp_type leadExp(const poly_type&) const = 0;
00094 
00096   virtual exp_type leadExp(const poly_type&, deg_type) const = 0;
00097 
00099   virtual poly_type leadFirst(const poly_type&) const = 0;
00100 
00102   virtual bool_type isLexicographical() const = 0;
00103 
00105   virtual bool_type orderedStandardIteration() const = 0;
00106 
00108   virtual bool_type isSymmetric() const = 0;
00109 
00111   virtual bool_type isDegreeOrder() const = 0;
00112 
00114   virtual bool_type isBlockOrder() const = 0;
00115 
00117   virtual bool_type isTotalDegreeOrder() const = 0;
00118 
00120   virtual bool_type ascendingVariables() const = 0;
00121 
00123   virtual bool_type descendingVariables() const = 0;
00124 
00126   virtual bool_type isDegreeReverseLexicographical() const = 0;
00127 
00129   virtual ordered_iterator leadIteratorBegin(const poly_type&) const = 0;
00130 
00132   virtual ordered_iterator leadIteratorEnd(const poly_type&) const = 0;
00133 
00135   virtual ordered_exp_iterator leadExpIteratorBegin(const poly_type&) const = 0;
00136 
00138   virtual ordered_exp_iterator leadExpIteratorEnd(const poly_type&) const = 0;
00139 
00141   virtual ordercode_type getOrderCode() const = 0;
00142 
00144   virtual ordercode_type getBaseOrderCode() const = 0 ;
00145 
00147 
00148   virtual block_iterator blockBegin() const { return block_iterator(); }
00149   virtual block_iterator blockEnd() const { return block_iterator(); }
00150   virtual void appendBlock(checked_idx_type) {}
00151   virtual void clearBlocks() {}
00153 
00156   virtual bool_type lieInSameBlock(idx_type, idx_type) const = 0;
00157 
00159   virtual idx_type lastBlockStart() const = 0;
00160 
00161 protected:
00163   monom_type monom(const set_type& rhs) const { 
00164     if PBORI_UNLIKELY(rhs.isZero())
00165       throw PBoRiGenericError<CTypes::illegal_on_zero>();
00166     return monom_type(rhs); 
00167   }
00168 };
00169 
00170 inline
00171 COrderingBase::~COrderingBase() { }
00172 
00173 END_NAMESPACE_PBORI
00174 
00175 #endif