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