1 | //! \file f5data.cc |
---|
2 | /**************************************** |
---|
3 | * Computer Algebra System SINGULAR * |
---|
4 | ****************************************/ |
---|
5 | /* $Id: f5data.h,v 1.8 2009-03-04 20:23:05 ederc Exp $ */ |
---|
6 | /* |
---|
7 | * ABSTRACT: labeled polynomial interface |
---|
8 | */ |
---|
9 | #ifndef F5DATA_HEADER |
---|
10 | #define F5DATA_HEADER |
---|
11 | #ifdef HAVE_F5 |
---|
12 | /*! |
---|
13 | ========================================================= |
---|
14 | ========================================================= |
---|
15 | classes for labeled polynomials/pairs/S-polynomials in F5 |
---|
16 | ========================================================= |
---|
17 | ========================================================= |
---|
18 | */ |
---|
19 | class LPoly; |
---|
20 | class CPair; |
---|
21 | class Rule; |
---|
22 | |
---|
23 | |
---|
24 | /*! |
---|
25 | ============================ |
---|
26 | class of labeled polynomials |
---|
27 | ============================ |
---|
28 | */ |
---|
29 | class LPoly { |
---|
30 | private: |
---|
31 | poly term; //term of signature |
---|
32 | int index; //index of signature |
---|
33 | poly polynomial; //standard polynomial data |
---|
34 | Rule* _rule; |
---|
35 | public: |
---|
36 | inline LPoly(poly t, int i, poly p, Rule* r=NULL); |
---|
37 | inline void setPoly(poly p); |
---|
38 | inline poly getPoly(); |
---|
39 | inline void setTerm(poly t); |
---|
40 | inline poly getTerm(); |
---|
41 | inline void setIndex(int i); |
---|
42 | inline int getIndex(); |
---|
43 | inline void setRule(Rule* r); |
---|
44 | inline Rule* getRule(); |
---|
45 | inline void set(poly t, int i, poly p, Rule* r); |
---|
46 | inline LPoly* get(); |
---|
47 | }; |
---|
48 | |
---|
49 | LPoly::LPoly(poly t,int i,poly p, Rule* r) { |
---|
50 | set(t,i,p,r); |
---|
51 | } |
---|
52 | |
---|
53 | void LPoly::setPoly(poly p) { |
---|
54 | //poly _p = pInit(); |
---|
55 | //_p = pCopy(p); |
---|
56 | polynomial = p; |
---|
57 | } |
---|
58 | |
---|
59 | void LPoly::setTerm(poly t) { |
---|
60 | //poly _t = pInit(); |
---|
61 | //_t = pCopy(t); |
---|
62 | term = t; |
---|
63 | } |
---|
64 | |
---|
65 | void LPoly::setIndex(int i) { |
---|
66 | index = i; |
---|
67 | } |
---|
68 | |
---|
69 | void LPoly::setRule(Rule* r) { |
---|
70 | _rule = r; |
---|
71 | } |
---|
72 | |
---|
73 | poly LPoly::getPoly() { |
---|
74 | return polynomial; |
---|
75 | } |
---|
76 | |
---|
77 | poly LPoly::getTerm() { |
---|
78 | return term; |
---|
79 | } |
---|
80 | |
---|
81 | int LPoly::getIndex() { |
---|
82 | return index; |
---|
83 | } |
---|
84 | |
---|
85 | Rule* LPoly::getRule() { |
---|
86 | return _rule; |
---|
87 | } |
---|
88 | |
---|
89 | void LPoly::set(poly t, int i, poly p, Rule* r) { |
---|
90 | this->setTerm(t); |
---|
91 | this->setIndex(i); |
---|
92 | this->setPoly(p); |
---|
93 | this->setRule(r); |
---|
94 | } |
---|
95 | |
---|
96 | LPoly* LPoly::get() { |
---|
97 | return this; |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | /*! |
---|
102 | =================================== |
---|
103 | structure of labeled critical pairs |
---|
104 | =================================== |
---|
105 | */ |
---|
106 | class CPair { |
---|
107 | private: |
---|
108 | long deg; // total degree of the critical pair |
---|
109 | poly t1; // first term for label |
---|
110 | LPoly* lp1; // first labeled poly |
---|
111 | poly t2; // second term for label |
---|
112 | LPoly* lp2; // second labeled poly |
---|
113 | Rule* testedRule; // already tested by rules up to lastRuleTested |
---|
114 | public: |
---|
115 | inline CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2, Rule* r = NULL); |
---|
116 | inline long getDeg(); |
---|
117 | inline poly getT1(); |
---|
118 | inline poly* getAdT1(); |
---|
119 | inline LPoly* getAdLp1(); |
---|
120 | inline poly getLp1Poly(); |
---|
121 | inline poly getLp1Term(); |
---|
122 | inline int getLp1Index(); |
---|
123 | inline poly getT2(); |
---|
124 | inline poly* getAdT2(); |
---|
125 | inline LPoly* getAdLp2(); |
---|
126 | inline poly getLp2Poly(); |
---|
127 | inline poly getLp2Term(); |
---|
128 | inline int getLp2Index(); |
---|
129 | inline Rule* getTestedRule(); |
---|
130 | inline void setTestedRule(Rule* r); |
---|
131 | }; |
---|
132 | |
---|
133 | CPair::CPair(long degree, poly term1, LPoly* lpoly1, poly term2, LPoly* lpoly2, Rule* r) { |
---|
134 | deg = degree; |
---|
135 | t1 = term1; |
---|
136 | lp1 = lpoly1; |
---|
137 | t2 = term2; |
---|
138 | lp2 = lpoly2; |
---|
139 | testedRule = r; |
---|
140 | } |
---|
141 | |
---|
142 | long CPair::getDeg() { |
---|
143 | return deg; |
---|
144 | } |
---|
145 | |
---|
146 | poly CPair::getT1() { |
---|
147 | return t1; |
---|
148 | } |
---|
149 | |
---|
150 | poly* CPair::getAdT1() { |
---|
151 | return &t1; |
---|
152 | } |
---|
153 | |
---|
154 | poly* CPair::getAdT2() { |
---|
155 | return &t2; |
---|
156 | } |
---|
157 | |
---|
158 | poly CPair::getT2() { |
---|
159 | return t2; |
---|
160 | } |
---|
161 | |
---|
162 | LPoly* CPair::getAdLp1() { |
---|
163 | return lp1; |
---|
164 | } |
---|
165 | |
---|
166 | LPoly* CPair::getAdLp2() { |
---|
167 | return lp2; |
---|
168 | } |
---|
169 | |
---|
170 | poly CPair::getLp1Poly() { |
---|
171 | return lp1->getPoly(); |
---|
172 | } |
---|
173 | |
---|
174 | poly CPair::getLp2Poly() { |
---|
175 | return lp2->getPoly(); |
---|
176 | } |
---|
177 | |
---|
178 | poly CPair::getLp1Term() { |
---|
179 | return lp1->getTerm(); |
---|
180 | } |
---|
181 | |
---|
182 | poly CPair::getLp2Term() { |
---|
183 | return lp2->getTerm(); |
---|
184 | } |
---|
185 | |
---|
186 | int CPair::getLp1Index() { |
---|
187 | return lp1->getIndex(); |
---|
188 | } |
---|
189 | |
---|
190 | int CPair::getLp2Index() { |
---|
191 | return lp2->getIndex(); |
---|
192 | } |
---|
193 | |
---|
194 | Rule* CPair::getTestedRule() { |
---|
195 | return testedRule; |
---|
196 | } |
---|
197 | |
---|
198 | void CPair::setTestedRule(Rule* r) { |
---|
199 | testedRule = r; |
---|
200 | } |
---|
201 | |
---|
202 | |
---|
203 | /*! |
---|
204 | ======================================================== |
---|
205 | structure of rules(i.e. already computed / known labels) |
---|
206 | ======================================================== |
---|
207 | */ |
---|
208 | class Rule { |
---|
209 | private: |
---|
210 | int index; // index of the labeled polynomial the rule comes from |
---|
211 | poly term; // term of the labeled polynomial the rule comes from |
---|
212 | public: |
---|
213 | inline Rule(int i, poly term); |
---|
214 | inline int getIndex(); |
---|
215 | inline poly getTerm(); |
---|
216 | }; |
---|
217 | |
---|
218 | Rule::Rule(int i, poly t) { |
---|
219 | index = i; |
---|
220 | term = t; |
---|
221 | } |
---|
222 | |
---|
223 | int Rule::getIndex() { |
---|
224 | return index; |
---|
225 | } |
---|
226 | |
---|
227 | poly Rule::getTerm() { |
---|
228 | return term; |
---|
229 | } |
---|
230 | #endif |
---|
231 | #endif |
---|