-
Notifications
You must be signed in to change notification settings - Fork 0
/
normal_strategy.cpp
67 lines (60 loc) · 2.75 KB
/
normal_strategy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __NORMAL_STRATEGY_CPP_
#define __NORMAL_STRATEGY_CPP_
/*****************************************************************************\
* This file is part of DynGB. *
* *
* DynGB is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* DynGB is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with DynGB. If not, see <http://www.gnu.org/licenses/>. *
\*****************************************************************************/
#include "critical_pair.hpp"
#include "normal_strategy.hpp"
Normal_Strategy::Normal_Strategy(Critical_Pair_Basic & cpb)
{
cp = &cpb;
}
bool Normal_Strategy::equivalent(const Pair_Strategy_Data & sd) const {
const Normal_Strategy * nsd = static_cast<const Normal_Strategy *>(&sd);
if (cp->second() == nullptr or nsd->cp->second() == nullptr)
return false;
else {
return (cp->lcm() == nsd->cp->lcm())
and (cp->first()->leading_monomial() == nsd->cp->first()->leading_monomial())
and (cp->second()->leading_monomial()
== nsd->cp->second()->leading_monomial());
}
}
bool Normal_Strategy::first_larger(const Pair_Strategy_Data & sd) const {
const Normal_Strategy * nsd = static_cast<const Normal_Strategy *>(&sd);
bool result = false;
if (cp->lcm() > nsd->cp->lcm())
result = true;
else if (cp->lcm().is_like(nsd->cp->lcm())) {
if (cp->first()->leading_monomial() > nsd->cp->first()->leading_monomial())
result = true;
else if (
cp->first()->leading_monomial().is_like(
nsd->cp->first()->leading_monomial()
)
) {
if (cp->second() != nullptr and nsd->cp->second() != nullptr)
result = (cp->second()->leading_monomial()
> nsd->cp->second()->leading_monomial());
}
}
return result;
}
ostream & operator <<(ostream &os, const Normal_Strategy &ns) {
os << "Normal Strategy recording lcm " << ns.cp->lcm();
return os;
}
#endif