Gröbner basis project
Codebase for research into Gröbner basis computation
normal_strategy.cpp
1 #ifndef __NORMAL_STRATEGY_CPP_
2 #define __NORMAL_STRATEGY_CPP_
3 
4 /*****************************************************************************\
5 * This file is part of DynGB. *
6 * *
7 * DynGB is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * Foobar is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
19 \*****************************************************************************/
20 
21 #include "critical_pair.hpp"
22 #include "normal_strategy.hpp"
23 
25 {
26  cp = &cpb;
27 }
28 
30  const Normal_Strategy * nsd = static_cast<const Normal_Strategy *>(&sd);
31  bool result = true;
32  if (cp->second() == nullptr or nsd->cp->second() == nullptr)
33  return false;
34  else {
35  return (cp->lcm() == nsd->cp->lcm())
36  and (cp->first()->leading_monomial() == nsd->cp->first()->leading_monomial())
37  and (cp->second()->leading_monomial()
38  == nsd->cp->second()->leading_monomial());
39  }
40 }
41 
43  const Normal_Strategy * nsd = static_cast<const Normal_Strategy *>(&sd);
44  bool result = false;
45  if (cp->lcm() > nsd->cp->lcm())
46  result = true;
47  else if (cp->lcm().is_like(nsd->cp->lcm())) {
48  if (cp->first()->leading_monomial() > nsd->cp->first()->leading_monomial())
49  result = true;
50  else if (
52  nsd->cp->first()->leading_monomial()
53  )
54  ) {
55  if (cp->second() != nullptr and nsd->cp->second() != nullptr)
56  result = (cp->second()->leading_monomial()
57  > nsd->cp->second()->leading_monomial());
58  }
59  }
60  return result;
61 }
62 
63 ostream & operator <<(ostream &os, const Normal_Strategy &ns) {
64  os << "Normal Strategy recording lcm " << ns.cp->lcm();
65  return os;
66 }
67 
68 #endif
const Abstract_Polynomial * second() const
second polynomial in pair
virtual bool equivalent(const Pair_Strategy_Data &sd) const
implementation of equivalent()
virtual bool first_larger(const Pair_Strategy_Data &sd) const
implementation of first_larger()
virtual Monomial & leading_monomial() const =0
leading monomial – call after sort_by_order()!
const Monomial & lcm() const
lcm of leading monomials of polynomials
Structure for sorting critical pairs.
Definition: strategies.hpp:145
Normal_Strategy(Critical_Pair_Basic &cpb)
all the information we need is in cpb already so no additional processing is necessary ...
const Abstract_Polynomial * first() const
first polynomial in pair
ordering critical pairs using the normal strategy
Critical_Pair_Basic * cp
the critical pair to which this Normal_Strategy belongs
bool is_like(const Monomial &other) const
Have same variables, same powers? Synonymous with operator==().
Definition: monomial.cpp:247
Controls the creation of s-polynomials.