1 | #ifndef POLYS_COMP_H |
---|
2 | #define POLYS_COMP_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: polys-comp.h,v 1.7 1998-04-30 15:29:34 obachman Exp $ */ |
---|
7 | |
---|
8 | /*************************************************************** |
---|
9 | * |
---|
10 | * File: polys-comp.h |
---|
11 | * Purpose: low-level monomial comparison routines |
---|
12 | * |
---|
13 | ***************************************************************/ |
---|
14 | |
---|
15 | #include "polys-impl.h" |
---|
16 | |
---|
17 | #ifdef WORDS_BIGENDIAN |
---|
18 | |
---|
19 | #define _pMonComp_otEXP_nwONE(p1, p2, d, actionD, actionE) \ |
---|
20 | do \ |
---|
21 | { \ |
---|
22 | d = *((long*) &(p1->exp[0])) - *((long*) &(p2->exp[0])); \ |
---|
23 | if (d) actionD; \ |
---|
24 | actionE; \ |
---|
25 | } \ |
---|
26 | while(0) |
---|
27 | |
---|
28 | #define _pMonComp_otEXPCOMP_nwONE(p1, p2, d, actionD, actionE) \ |
---|
29 | do \ |
---|
30 | { \ |
---|
31 | d = *((long*) &(p1->exp[0])) - *((long*) &(p2->exp[0])); \ |
---|
32 | if (d) \ |
---|
33 | { \ |
---|
34 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
35 | d = -d; \ |
---|
36 | actionD; \ |
---|
37 | } \ |
---|
38 | actionE; \ |
---|
39 | } \ |
---|
40 | while(0) |
---|
41 | |
---|
42 | #define _pMonComp_otEXP_nwTWO(p1, p2, d, actionD, actionE) \ |
---|
43 | do \ |
---|
44 | { \ |
---|
45 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
46 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
47 | d = *s1 - *s2; \ |
---|
48 | if (d) actionD; \ |
---|
49 | d = *(s1 + 1) - *(s2 + 1); \ |
---|
50 | if (d) actionD; \ |
---|
51 | actionE; \ |
---|
52 | } \ |
---|
53 | while(0) |
---|
54 | |
---|
55 | #define _pMonComp_otEXPCOMP_nwTWO(p1, p2, d, actionD, actionE) \ |
---|
56 | do \ |
---|
57 | { \ |
---|
58 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
59 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
60 | d = *s1 - *s2; \ |
---|
61 | if (d) actionD; \ |
---|
62 | d = *(s1 + 1) - *(s2 + 1); \ |
---|
63 | if (d) \ |
---|
64 | { \ |
---|
65 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
66 | d = -d; \ |
---|
67 | actionD; \ |
---|
68 | } \ |
---|
69 | actionE; \ |
---|
70 | } \ |
---|
71 | while(0) |
---|
72 | |
---|
73 | #define _pMonComp_otEXP_nwEVEN(p1, p2, length, d, actionD, actionE) \ |
---|
74 | do \ |
---|
75 | { \ |
---|
76 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
77 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
78 | const long* const lb = s1 + length; \ |
---|
79 | \ |
---|
80 | for (;;) \ |
---|
81 | { \ |
---|
82 | d = *s1 - *s2; \ |
---|
83 | if (d) actionD; \ |
---|
84 | s1++; \ |
---|
85 | s2++; \ |
---|
86 | d = *s1 - *s2; \ |
---|
87 | if (d) actionD; \ |
---|
88 | s1++; \ |
---|
89 | if (s1 == lb) actionE; \ |
---|
90 | s2++; \ |
---|
91 | } \ |
---|
92 | } \ |
---|
93 | while(0) |
---|
94 | |
---|
95 | #define _pMonComp_otEXP_nwODD(p1, p2, length, d, actionD, actionE) \ |
---|
96 | do \ |
---|
97 | { \ |
---|
98 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
99 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
100 | const long* const lb = s1 + length; \ |
---|
101 | \ |
---|
102 | for (;;) \ |
---|
103 | { \ |
---|
104 | d = *s1 - *s2; \ |
---|
105 | if (d) actionD; \ |
---|
106 | s1++; \ |
---|
107 | if (s1 == lb) actionE; \ |
---|
108 | s2++; \ |
---|
109 | d = *s1 - *s2; \ |
---|
110 | if (d) actionD; \ |
---|
111 | s1++; \ |
---|
112 | s2++; \ |
---|
113 | } \ |
---|
114 | } \ |
---|
115 | while(0) |
---|
116 | |
---|
117 | #define _pMonComp_otEXPCOMP_nwEVEN(p1, p2, length, d, actionD, actionE) \ |
---|
118 | do \ |
---|
119 | { \ |
---|
120 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
121 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
122 | const long* const lb = s1 + length-1; \ |
---|
123 | \ |
---|
124 | for (;;) \ |
---|
125 | { \ |
---|
126 | d = *s1 - *s2; \ |
---|
127 | if (d) actionD; \ |
---|
128 | s1++; \ |
---|
129 | if (s1 == lb) break; \ |
---|
130 | s2++; \ |
---|
131 | d = *s1 - *s2; \ |
---|
132 | if (d) actionD; \ |
---|
133 | s1++; \ |
---|
134 | s2++; \ |
---|
135 | } \ |
---|
136 | \ |
---|
137 | d = *s1 - *(s2 + 1); \ |
---|
138 | if (d) \ |
---|
139 | { \ |
---|
140 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
141 | d = -d; \ |
---|
142 | actionD; \ |
---|
143 | } \ |
---|
144 | actionE; \ |
---|
145 | } \ |
---|
146 | while(0) |
---|
147 | |
---|
148 | #define _pMonComp_otEXPCOMP_nwODD(p1, p2, length, d, actionD, actionE) \ |
---|
149 | do \ |
---|
150 | { \ |
---|
151 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
152 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
153 | const long* const lb = s1 + length -1; \ |
---|
154 | \ |
---|
155 | for (;;) \ |
---|
156 | { \ |
---|
157 | d = *s1 - *s2; \ |
---|
158 | if (d) actionD; \ |
---|
159 | s1++; \ |
---|
160 | s2++; \ |
---|
161 | d = *s1 - *s2; \ |
---|
162 | if (d) actionD; \ |
---|
163 | s1++; \ |
---|
164 | if (s1 == lb) break; \ |
---|
165 | s2++; \ |
---|
166 | } \ |
---|
167 | \ |
---|
168 | d = *s1 - *(s2 + 1); \ |
---|
169 | if (d) \ |
---|
170 | { \ |
---|
171 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
172 | d = -d; \ |
---|
173 | actionD; \ |
---|
174 | } \ |
---|
175 | actionE; \ |
---|
176 | } \ |
---|
177 | while(0) |
---|
178 | |
---|
179 | #define _pMonComp_otEXP_nwGEN(p1, p2, length, d, actionD, actionE) \ |
---|
180 | do \ |
---|
181 | { \ |
---|
182 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
183 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
184 | const long* const lb = s1 + length; \ |
---|
185 | \ |
---|
186 | for (;;) \ |
---|
187 | { \ |
---|
188 | d = *s1 - *s2; \ |
---|
189 | if (d) actionD; \ |
---|
190 | s1++; \ |
---|
191 | if (s1 == lb) actionE; \ |
---|
192 | s2++; \ |
---|
193 | } \ |
---|
194 | } \ |
---|
195 | while(0) |
---|
196 | |
---|
197 | #define _pMonComp_otEXPCOMP_nwGEN(p1, p2, length, d, actionD, actionE) \ |
---|
198 | do \ |
---|
199 | { \ |
---|
200 | const long* s1 = (long*) &(p1->exp[0]); \ |
---|
201 | const long* s2 = (long*) &(p2->exp[0]); \ |
---|
202 | const long* const lb = s1 + length -1; \ |
---|
203 | \ |
---|
204 | for (;;) \ |
---|
205 | { \ |
---|
206 | d = *s1 - *s2; \ |
---|
207 | if (d) actionD; \ |
---|
208 | s1++; \ |
---|
209 | if (s1 == lb) break; \ |
---|
210 | s2++; \ |
---|
211 | } \ |
---|
212 | \ |
---|
213 | d = *s1 - *(s2 + 1); \ |
---|
214 | if (d) \ |
---|
215 | { \ |
---|
216 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
217 | d = -d; \ |
---|
218 | actionD; \ |
---|
219 | } \ |
---|
220 | actionE; \ |
---|
221 | } \ |
---|
222 | while(0) |
---|
223 | |
---|
224 | |
---|
225 | #else // ! WORDS_BIGENDIAN |
---|
226 | |
---|
227 | #define _pMonComp_otEXP_nwONE(p1, p2, d, actionD, actionE) \ |
---|
228 | do \ |
---|
229 | { \ |
---|
230 | d = *(((long*) p1) + pMonomSizeW-1) - *(((long*) p2) + pMonomSizeW-1); \ |
---|
231 | if (d) actionD; \ |
---|
232 | actionE; \ |
---|
233 | } \ |
---|
234 | while(0) |
---|
235 | |
---|
236 | #define _pMonComp_otEXPCOMP_nwONE(p1, p2, d, actionD, actionE) \ |
---|
237 | do \ |
---|
238 | { \ |
---|
239 | d = *(((long*) p1) + pMonomSizeW-1) - *(((long*) p2) + pMonomSizeW-1); \ |
---|
240 | if (d) \ |
---|
241 | { \ |
---|
242 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
243 | d = -d; \ |
---|
244 | actionD; \ |
---|
245 | } \ |
---|
246 | actionE; \ |
---|
247 | } \ |
---|
248 | while(0) |
---|
249 | |
---|
250 | #define _pMonComp_otEXP_nwTWO(p1, p2, d, actionD, actionE) \ |
---|
251 | do \ |
---|
252 | { \ |
---|
253 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
254 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
255 | d = *s1 - *s2; \ |
---|
256 | if (d) actionD; \ |
---|
257 | d = *(s1 - 1) - *(s2 - 1); \ |
---|
258 | if (d) actionD; \ |
---|
259 | actionE; \ |
---|
260 | } \ |
---|
261 | while(0) |
---|
262 | |
---|
263 | #define _pMonComp_otEXPCOMP_nwTWO(p1, p2, d, actionD, actionE) \ |
---|
264 | do \ |
---|
265 | { \ |
---|
266 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
267 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
268 | d = *s1 - *s2; \ |
---|
269 | if (d) actionD; \ |
---|
270 | d = *s1 - *s2; \ |
---|
271 | if (d) actionD; \ |
---|
272 | d = *(s1 -1) - *(s2 -1); \ |
---|
273 | if (d) \ |
---|
274 | { \ |
---|
275 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
276 | d = -d; \ |
---|
277 | actionD; \ |
---|
278 | } \ |
---|
279 | actionE; \ |
---|
280 | } \ |
---|
281 | while(0) |
---|
282 | |
---|
283 | #define _pMonComp_otEXP_nwEVEN(p1, p2, length, d, actionD, actionE) \ |
---|
284 | do \ |
---|
285 | { \ |
---|
286 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
287 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
288 | const long* const lb = s1 - length; \ |
---|
289 | for (;;) \ |
---|
290 | { \ |
---|
291 | d = *s1 - *s2; \ |
---|
292 | if (d) actionD; \ |
---|
293 | s1--; \ |
---|
294 | s2--; \ |
---|
295 | d = *s1 - *s2; \ |
---|
296 | if (d) actionD; \ |
---|
297 | s1--; \ |
---|
298 | if (s1 == lb) actionE; \ |
---|
299 | s2--; \ |
---|
300 | } \ |
---|
301 | } \ |
---|
302 | while(0) |
---|
303 | |
---|
304 | #define _pMonComp_otEXP_nwODD(p1, p2, length, d, actionD, actionE) \ |
---|
305 | do \ |
---|
306 | { \ |
---|
307 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
308 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
309 | const long* const lb = s1 - length; \ |
---|
310 | \ |
---|
311 | for (;;) \ |
---|
312 | { \ |
---|
313 | d = *s1 - *s2; \ |
---|
314 | if (d) actionD; \ |
---|
315 | s1--; \ |
---|
316 | if (s1 == lb) actionE; \ |
---|
317 | s2--; \ |
---|
318 | d = *s1 - *s2; \ |
---|
319 | if (d) actionD; \ |
---|
320 | s1--; \ |
---|
321 | s2--; \ |
---|
322 | } \ |
---|
323 | } \ |
---|
324 | while(0) |
---|
325 | |
---|
326 | #define _pMonComp_otEXPCOMP_nwEVEN(p1, p2, length, d, actionD, actionE) \ |
---|
327 | do \ |
---|
328 | { \ |
---|
329 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
330 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
331 | const long* const lb = s1 - length +1; \ |
---|
332 | \ |
---|
333 | for (;;) \ |
---|
334 | { \ |
---|
335 | d = *s1 - *s2; \ |
---|
336 | if (d) actionD; \ |
---|
337 | s1--; \ |
---|
338 | if (s1 == lb) break; \ |
---|
339 | s2--; \ |
---|
340 | d = *s1 - *s2; \ |
---|
341 | if (d) actionD; \ |
---|
342 | s1--; \ |
---|
343 | s2--; \ |
---|
344 | } \ |
---|
345 | \ |
---|
346 | d = *s1 - *(s2 - 1); \ |
---|
347 | if (d) \ |
---|
348 | { \ |
---|
349 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
350 | d = -d; \ |
---|
351 | actionD; \ |
---|
352 | } \ |
---|
353 | actionE; \ |
---|
354 | } \ |
---|
355 | while(0) |
---|
356 | |
---|
357 | #define _pMonComp_otEXPCOMP_nwODD(p1, p2, length, d, actionD, actionE) \ |
---|
358 | do \ |
---|
359 | { \ |
---|
360 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
361 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
362 | const long* const lb = s1 - length +1; \ |
---|
363 | \ |
---|
364 | for (;;) \ |
---|
365 | { \ |
---|
366 | d = *s1 - *s2; \ |
---|
367 | if (d) actionD; \ |
---|
368 | s1--; \ |
---|
369 | s2--; \ |
---|
370 | d = *s1 - *s2; \ |
---|
371 | if (d) actionD; \ |
---|
372 | s1--; \ |
---|
373 | if (s1 == lb) break; \ |
---|
374 | s2--; \ |
---|
375 | } \ |
---|
376 | \ |
---|
377 | d = *s1 - *(s2 - 1); \ |
---|
378 | if (d) \ |
---|
379 | { \ |
---|
380 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
381 | d = -d; \ |
---|
382 | actionD; \ |
---|
383 | } \ |
---|
384 | actionE; \ |
---|
385 | } \ |
---|
386 | while(0) |
---|
387 | |
---|
388 | #define _pMonComp_otEXP_nwGEN(p1, p2, length, d, actionD, actionE) \ |
---|
389 | do \ |
---|
390 | { \ |
---|
391 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
392 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
393 | const long* const lb = s1 - length; \ |
---|
394 | \ |
---|
395 | for (;;) \ |
---|
396 | { \ |
---|
397 | d = *s1 - *s2; \ |
---|
398 | if (d) actionD; \ |
---|
399 | s1--; \ |
---|
400 | if (s1 == lb) actionE; \ |
---|
401 | s2--; \ |
---|
402 | } \ |
---|
403 | } \ |
---|
404 | while(0) |
---|
405 | |
---|
406 | #define _pMonComp_otEXPCOMP_nwGEN(p1, p2, length, d, actionD, actionE) \ |
---|
407 | do \ |
---|
408 | { \ |
---|
409 | const long* s1 = ((long*) p1) + pMonomSizeW-1; \ |
---|
410 | const long* s2 = ((long*) p2) + pMonomSizeW-1; \ |
---|
411 | const long* const lb = s1 - length +1; \ |
---|
412 | \ |
---|
413 | for (;;) \ |
---|
414 | { \ |
---|
415 | d = *s1 - *s2; \ |
---|
416 | if (d) actionD; \ |
---|
417 | s1--; \ |
---|
418 | if (s1 == lb) break; \ |
---|
419 | s2--; \ |
---|
420 | } \ |
---|
421 | \ |
---|
422 | d = *s1 - *(s2 - 1); \ |
---|
423 | if (d) \ |
---|
424 | { \ |
---|
425 | if (((long) (pGetComp(p1) - pGetComp(p2))) == d) \ |
---|
426 | d = -d; \ |
---|
427 | actionD; \ |
---|
428 | } \ |
---|
429 | actionE; \ |
---|
430 | } \ |
---|
431 | while(0) |
---|
432 | |
---|
433 | #endif // WORDS_BIGENDIAN |
---|
434 | |
---|
435 | #endif // POLYS_COMP_H |
---|
436 | |
---|