00001
00002
00014
00015
00016 #ifndef polybori_groebner_RelatedTermsBase_h_
00017 #define polybori_groebner_RelatedTermsBase_h_
00018
00019 #include "minimal_elements.h"
00020 #include <polybori/ring/CMemberFunctionTraits.h>
00021 #include "BoundedDivisorsOf.h"
00022
00023
00024 #include "groebner_defs.h"
00025
00026 BEGIN_NAMESPACE_PBORIGB
00027
00032 class RelatedTermsBase {
00033
00034 public:
00036 RelatedTermsBase(const BoolePolyRing& ring):
00037 m_lead(ring), m_ignorable(ring), m_ext_prod_terms(ring),
00038 m_related(ring), m_divisors_of(ring, ring) { }
00039
00041 RelatedTermsBase(const Monomial& lead, const MonomialSet& terms,
00042 const MonomialSet& ignorable, const MonomialSet& significant):
00043 m_lead(lead), m_ignorable(ignorable), m_ext_prod_terms(lead.ring()),
00044 m_related(lead.ring()), m_divisors_of(lead, significant) {
00045
00046 init(significant, unrelated_terms(significant));
00047 }
00048
00050 const MonomialSet& related_terms() const { return m_related; }
00051
00053 const BoundedDivisorsOf& divisors_of() const { return m_divisors_of; }
00054
00056 MonomialSet factors(const MonomialSet& terms) const {
00057 return minimal_elements_divided(critical_terms_base(terms), m_lead,
00058 m_ext_prod_terms);
00059 }
00060
00062 MonomialSet critical_terms_base(const MonomialSet& terms) const {
00063 return mod_mon_set(m_related.intersect(terms), m_ignorable);
00064 }
00065
00067 MonomialSet unrelated_terms(const MonomialSet& terms) const {
00068 return std::accumulate(m_lead.begin(), m_lead.end(), terms,
00069 member_function_operator(&MonomialSet::subset0) );
00070 }
00071
00072 private:
00074 void init(const MonomialSet& significant, const MonomialSet& unrelated) {
00075 PBORI_ASSERT(!m_ignorable.owns(m_lead) && !significant.ownsOne());
00076 m_related = significant.diff(unrelated);
00077 m_ext_prod_terms = m_ignorable.existAbstract(m_lead).diff(unrelated);
00078 }
00079
00080 Monomial m_lead;
00081 MonomialSet m_ignorable;
00082 MonomialSet m_ext_prod_terms;
00083
00084 MonomialSet m_related;
00085 BoundedDivisorsOf m_divisors_of;
00086 };
00087
00088 END_NAMESPACE_PBORIGB
00089
00090 #endif