carl  24.04
Computer ARithmetic Library
CriticalPairs.h
Go to the documentation of this file.
1 
2 
3 
4 /**
5  * @file CriticalPairs.h
6  * @ingroup gb
7  * @author Sebastian Junges
8  */
9 #pragma once
10 
14 #include "CriticalPairsEntry.h"
15 
16 #include <unordered_map>
17 
18 namespace carl
19 {
20 
21 template< class Compare>
23 {
24 public:
27 
28  static CompareResult compare( Entry e1, Entry e2 )
29  {
30  return Compare::compare( e1->getSortedFirstLCM( ), e2->getSortedFirstLCM( ) );
31  }
32 
33  static bool cmpLessThan( CompareResult res )
34  {
35  return res == CompareResult::GREATER;
36  }
37  static const bool supportDeduplicationWhileOrdering = false;
38 
39  static bool cmpEqual( CompareResult res )
40  {
41  return res == CompareResult::EQUAL;
42  }
43 
44  using Order = Compare;
45  static const bool fastIndex = true;
46 };
47 
48 
49 /**
50  * A data structure to store all the SPolynomial pairs which have to be checked.
51  */
52 template<template <class> class Datastructure, class Configuration>
54 {
55 public:
56 
57  CriticalPairs( ) : mDatastruct( Configuration( ) )
58  {
59 
60  }
61 
62  /**
63  * Add a list of s-pairs to the list.
64  * @param pairs
65  */
66  void push( std::list<SPolPair> pairs )
67  {
68  if( pairs.empty( ) ) return;
69  mDatastruct.push( new CriticalPairsEntry<typename Configuration::Order > ( std::move(pairs) ) );
70  }
71 
72  /**
73  * Gets the first SPol from the data structure and removes it from the data structure.
74  * @return
75  */
77  /**
78  * Eliminate multiples of the given monomial.
79  * @param lm
80  * @param newpairs
81  */
82  void elimMultiples( const Monomial::Arg& lm, const std::unordered_map<size_t, SPolPair>& newpairs );
83 
84  /**
85  * Checks whether there are any pairs in the data structure.
86  * @return
87  */
88  bool empty( ) const
89  {
90  return mDatastruct.empty( );
91  }
92 
93  /**
94  * Print the underlying data structure.
95  */
96  void print( ) const
97  {
98  mDatastruct.print( );
99  }
100 
101  /**
102  * Checks the size of the data structure.
103  * Please notice that this is not necessarily the number of pairs in the data structure, as the underlying elements may be lists themselves.
104  * @return
105  */
106  unsigned size( ) const
107  {
108  return mDatastruct.size( );
109  }
110 
111 private:
112  Datastructure<Configuration> mDatastruct;
113 };
114 
116 
117 
118 }
119 
120 #include "CriticalPairs.tpp"
This file has been extracted from mathic.
carl is the main namespace for the library.
CriticalPairs< Heap, CriticalPairConfiguration< GrLexOrdering > > CritPairs
signed compare(const BasicConstraint< Pol > &_constraintA, const BasicConstraint< Pol > &_constraintB)
Compares _constraintA with _constraintB.
Definition: Comparison.h:25
CompareResult
Definition: CompareResult.h:12
@ GREATER
Definition: SignCondition.h:15
static bool cmpEqual(CompareResult res)
Definition: CriticalPairs.h:39
static CompareResult compare(Entry e1, Entry e2)
Definition: CriticalPairs.h:28
static const bool supportDeduplicationWhileOrdering
Definition: CriticalPairs.h:37
static bool cmpLessThan(CompareResult res)
Definition: CriticalPairs.h:33
A data structure to store all the SPolynomial pairs which have to be checked.
Definition: CriticalPairs.h:54
void push(std::list< SPolPair > pairs)
Add a list of s-pairs to the list.
Definition: CriticalPairs.h:66
SPolPair pop()
Gets the first SPol from the data structure and removes it from the data structure.
void print() const
Print the underlying data structure.
Definition: CriticalPairs.h:96
bool empty() const
Checks whether there are any pairs in the data structure.
Definition: CriticalPairs.h:88
void elimMultiples(const Monomial::Arg &lm, const std::unordered_map< size_t, SPolPair > &newpairs)
Eliminate multiples of the given monomial.
unsigned size() const
Checks the size of the data structure.
Datastructure< Configuration > mDatastruct
A list of SPol pairs which have to be checked by the Buchberger algorithm.
const Monomial::Arg & getSortedFirstLCM() const
Get the LCM of the first element.
Basic spol-pair.
Definition: SPolPair.h:20
std::shared_ptr< const Monomial > Arg
Definition: Monomial.h:62