1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: f5lists.h,v 1.5 2009-02-04 19:27:12 ederc Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: list interface |
---|
7 | */ |
---|
8 | #include "f5data.h" |
---|
9 | #ifndef F5LISTS_HEADER |
---|
10 | #define F5LISTS_HEADER |
---|
11 | |
---|
12 | #ifdef HAVE_F5 |
---|
13 | /* |
---|
14 | ============================ |
---|
15 | ============================ |
---|
16 | classes for lists used in F5 |
---|
17 | ============================ |
---|
18 | ============================ |
---|
19 | */ |
---|
20 | class LNode; |
---|
21 | class LList; |
---|
22 | class LTagNode; |
---|
23 | class LTagList; |
---|
24 | class CNode; |
---|
25 | class CList; |
---|
26 | class RList; |
---|
27 | class RNode; |
---|
28 | class RTagNode; |
---|
29 | class RTagList; |
---|
30 | |
---|
31 | |
---|
32 | /* |
---|
33 | ======================================= |
---|
34 | class LNode (nodes for lists of LPolys) |
---|
35 | ======================================= |
---|
36 | */ |
---|
37 | class LNode { |
---|
38 | private: |
---|
39 | LPoly* data; |
---|
40 | LNode* next; |
---|
41 | public: |
---|
42 | // generating new list elements from the labeled / classical polynomial view |
---|
43 | LNode(LPoly* lp); |
---|
44 | LNode(LPoly* lp, LNode* l); |
---|
45 | LNode(poly* t, int* i, poly* p); |
---|
46 | LNode(poly* t, int* i, poly* p, LNode* l); |
---|
47 | LNode(LNode* ln); |
---|
48 | ~LNode(); |
---|
49 | // insert new elements to the list in first place from the labeled / classical polynomial view |
---|
50 | LNode* insert(LPoly* lp); |
---|
51 | LNode* insert(poly* t, int* i, poly* p); |
---|
52 | // insert new elements to the list with resp. to increasing labels |
---|
53 | // only used for the S-polys to be reduced (TopReduction building new S-polys with higher label) |
---|
54 | LNode* insertByLabel(LPoly* lp); |
---|
55 | // deletes the first elements of the list with the same degree |
---|
56 | // get next from current LNode |
---|
57 | LNode* getNext(); |
---|
58 | // only used for the S-polys, which are already sorted by increasing degree by CList |
---|
59 | LNode* deleteByDeg(); |
---|
60 | // get the LPoly* out of LNode* |
---|
61 | LPoly* getLPoly(); |
---|
62 | // get the data from the LPoly saved in LNode |
---|
63 | poly getPoly(); |
---|
64 | poly getTerm(); |
---|
65 | int getIndex(); |
---|
66 | // test if for any list element the polynomial part of the data is equal to *p |
---|
67 | bool polyTest(poly* p); |
---|
68 | LNode* getNext(LNode* l); |
---|
69 | }; |
---|
70 | |
---|
71 | |
---|
72 | /* |
---|
73 | ============================ |
---|
74 | class LList(lists of LPolys) |
---|
75 | ============================ |
---|
76 | */ |
---|
77 | class LList { |
---|
78 | private: |
---|
79 | LNode* first; |
---|
80 | public: |
---|
81 | LList(LPoly* lp); |
---|
82 | LList(poly* t,int* i,poly* p); |
---|
83 | ~LList(); |
---|
84 | void insert(LPoly* lp); |
---|
85 | // insertion in front of the list |
---|
86 | void insert(poly* t,int* i, poly* p); |
---|
87 | void insertByLabel(LPoly* lp); |
---|
88 | void deleteByDeg(); |
---|
89 | bool polyTest(poly* p); |
---|
90 | LNode* getFirst(); |
---|
91 | LNode* getNext(LNode* l); |
---|
92 | }; |
---|
93 | |
---|
94 | |
---|
95 | /* |
---|
96 | ============================================== |
---|
97 | class LtagNode (nodes for lists of LPoly tags) |
---|
98 | ============================================== |
---|
99 | */ |
---|
100 | class LTagNode { |
---|
101 | private: |
---|
102 | LNode* data; |
---|
103 | LTagNode* next; |
---|
104 | public: |
---|
105 | LTagNode(LNode* l); |
---|
106 | LTagNode(LNode* l, LTagNode* n); |
---|
107 | ~LTagNode(); |
---|
108 | // declaration with first as parameter due to sorting of LTagList |
---|
109 | LTagNode* insert(LNode* l); |
---|
110 | LNode* getLNode(); |
---|
111 | LNode* get(int i, int length); |
---|
112 | }; |
---|
113 | |
---|
114 | |
---|
115 | /* |
---|
116 | ========================================================================= |
---|
117 | class LTagList(lists of LPoly tags, i.e. first elements of a given index) |
---|
118 | ========================================================================= |
---|
119 | */ |
---|
120 | class LTagList { |
---|
121 | private: |
---|
122 | LTagNode* first; |
---|
123 | int length; |
---|
124 | public: |
---|
125 | LTagList(LNode* l); |
---|
126 | ~LTagList(); |
---|
127 | // declaration with first as parameter in LTagNode due to sorting of LTagList |
---|
128 | void insert(LNode* l); |
---|
129 | LNode* get(int idx); |
---|
130 | }; |
---|
131 | |
---|
132 | |
---|
133 | /* |
---|
134 | ======================================= |
---|
135 | class CNode (nodes for lists of CPairs) |
---|
136 | ======================================= |
---|
137 | */ |
---|
138 | class CNode { |
---|
139 | private: |
---|
140 | CPair* data; |
---|
141 | CNode* next; |
---|
142 | public: |
---|
143 | CNode(); |
---|
144 | CNode(CPair* c); |
---|
145 | CNode(CPair* c, CNode* n); |
---|
146 | ~CNode(); |
---|
147 | CNode* insert(CPair* c, CNode* last); |
---|
148 | CNode* getMinDeg(); |
---|
149 | poly getLp1Poly(); |
---|
150 | poly getLp2Poly(); |
---|
151 | poly getLp1Term(); |
---|
152 | poly getLp2Term(); |
---|
153 | poly getT1(); |
---|
154 | poly getT2(); |
---|
155 | int getLp1Index(); |
---|
156 | int getLp2Index(); |
---|
157 | void print(); |
---|
158 | }; |
---|
159 | |
---|
160 | |
---|
161 | /* |
---|
162 | ============================ |
---|
163 | class CList(lists of CPairs) |
---|
164 | ============================ |
---|
165 | */ |
---|
166 | class CList { |
---|
167 | private: |
---|
168 | CNode* first; |
---|
169 | // last alway has data=NULL and next=NULL, for initialization purposes used |
---|
170 | CNode* last; |
---|
171 | public: |
---|
172 | // for initialization of CLists, last element alwas has data=NULL and next=NULL |
---|
173 | CList(); |
---|
174 | CList(CPair* c); |
---|
175 | ~CList(); |
---|
176 | void insert(CPair* c); |
---|
177 | CNode* getMinDeg(); |
---|
178 | void print(); |
---|
179 | }; |
---|
180 | |
---|
181 | |
---|
182 | /* |
---|
183 | ====================================== |
---|
184 | class RNode (nodes for lists of Rules) |
---|
185 | ====================================== |
---|
186 | */ |
---|
187 | class RNode { |
---|
188 | private: |
---|
189 | Rule* data; |
---|
190 | RNode* next; |
---|
191 | public: |
---|
192 | RNode(); |
---|
193 | RNode(Rule* r); |
---|
194 | ~RNode(); |
---|
195 | RNode* insert(Rule* r); |
---|
196 | RNode* getNext(); |
---|
197 | Rule* getRule(); |
---|
198 | int getRuleIndex(); |
---|
199 | poly getRuleTerm(); |
---|
200 | }; |
---|
201 | |
---|
202 | /* |
---|
203 | ============================ |
---|
204 | class RList (lists of Rules) |
---|
205 | ============================ |
---|
206 | */ |
---|
207 | class RList { |
---|
208 | private: |
---|
209 | RNode* first; |
---|
210 | // last alway has data=NULL and next=NULL, for initialization purposes used |
---|
211 | RNode* last; |
---|
212 | public: |
---|
213 | RList(); |
---|
214 | RList(Rule* r); |
---|
215 | ~RList(); |
---|
216 | void insert(Rule* r); |
---|
217 | RNode* getFirst(); |
---|
218 | Rule* getRule(); |
---|
219 | }; |
---|
220 | |
---|
221 | |
---|
222 | |
---|
223 | /* |
---|
224 | ============================================= |
---|
225 | class RtagNode (nodes for lists of Rule tags) |
---|
226 | ============================================= |
---|
227 | */ |
---|
228 | class RTagNode { |
---|
229 | private: |
---|
230 | RNode* data; |
---|
231 | RTagNode* next; |
---|
232 | public: |
---|
233 | RTagNode(); |
---|
234 | RTagNode(RNode* r); |
---|
235 | RTagNode(RNode* r, RTagNode* n); |
---|
236 | ~RTagNode(); |
---|
237 | // declaration with first as parameter due to sorting of LTagList |
---|
238 | RTagNode* insert(RNode* r); |
---|
239 | RNode* getRNode(); |
---|
240 | RNode* get(int idx, int length); |
---|
241 | }; |
---|
242 | |
---|
243 | |
---|
244 | /* |
---|
245 | ======================================================================== |
---|
246 | class RTagList(lists of Rule tags, i.e. first elements of a given index) |
---|
247 | ======================================================================== |
---|
248 | */ |
---|
249 | class RTagList { |
---|
250 | private: |
---|
251 | RTagNode* first; |
---|
252 | int length; |
---|
253 | public: |
---|
254 | RTagList(); |
---|
255 | RTagList(RNode* r); |
---|
256 | ~RTagList(); |
---|
257 | // declaration with first as parameter in LTagNode due to sorting of LTagList |
---|
258 | void insert(RNode* r); |
---|
259 | RNode* getFirst(); |
---|
260 | RNode* get(int idx); |
---|
261 | }; |
---|
262 | #endif |
---|
263 | #endif |
---|