1 | #ifndef POLYS_COMP_H |
---|
2 | #define POLYS_COMP_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: polys-comp.h,v 1.22 2000-03-22 11:20:54 Singular 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 | // need to undefine this, since longs might be negative |
---|
18 | #define u_s |
---|
19 | |
---|
20 | #ifdef WORDS_BIGENDIAN |
---|
21 | |
---|
22 | #define _memcmp(p1, p2, i, l, actionE, actionD) \ |
---|
23 | do \ |
---|
24 | { \ |
---|
25 | i = 0; \ |
---|
26 | while (i < l) \ |
---|
27 | { \ |
---|
28 | if (p1[i] != p2[i]) actionD; \ |
---|
29 | i++; \ |
---|
30 | } \ |
---|
31 | actionE; \ |
---|
32 | } \ |
---|
33 | while (0) |
---|
34 | |
---|
35 | #define _prMonCmp(p1, p2, r, actionE, actionG, actionS) \ |
---|
36 | do \ |
---|
37 | { \ |
---|
38 | register const u_s long* s1 = &(p1->exp.l[r->pCompLowIndex]); \ |
---|
39 | register const u_s long* s2 = &(p2->exp.l[r->pCompLowIndex]); \ |
---|
40 | int _l = r->pCompLSize; \ |
---|
41 | register int _i; \ |
---|
42 | _memcmp(s1, s2, _i, _l, actionE, goto _NotEqual); \ |
---|
43 | \ |
---|
44 | _NotEqual: \ |
---|
45 | if (r->ordsgn[_i] != 1) \ |
---|
46 | { \ |
---|
47 | if (s2[_i] > s1[_i]) actionG; \ |
---|
48 | actionS; \ |
---|
49 | } \ |
---|
50 | if (s1[_i] > s2[_i]) actionG; \ |
---|
51 | actionS; \ |
---|
52 | } \ |
---|
53 | while (0) |
---|
54 | |
---|
55 | #else // ! WORDS_BIGENDIAN |
---|
56 | |
---|
57 | #define _memcmp(p1, p2, i, actionE, actionD) \ |
---|
58 | do \ |
---|
59 | { \ |
---|
60 | for (;;) \ |
---|
61 | { \ |
---|
62 | if (p1[i] != p2[i]) actionD; \ |
---|
63 | if (i == 0) actionE; \ |
---|
64 | i--; \ |
---|
65 | } \ |
---|
66 | } \ |
---|
67 | while (0) |
---|
68 | |
---|
69 | #define register |
---|
70 | |
---|
71 | #define _prMonCmp(p1, p2, r, actionE, actionG, actionS) \ |
---|
72 | do \ |
---|
73 | { \ |
---|
74 | register const u_s long* __s1 = \ |
---|
75 | (const long *)&(p1->exp.l[r->pCompLowIndex]); \ |
---|
76 | register const u_s long* __s2 = \ |
---|
77 | (const long *)&(p2->exp.l[r->pCompLowIndex]); \ |
---|
78 | register int __i = r->pCompLSize - 1; \ |
---|
79 | _memcmp(__s1, __s2, __i, actionE, goto _NotEqual); \ |
---|
80 | \ |
---|
81 | _NotEqual: \ |
---|
82 | if (r->ordsgn[__i] != 1) \ |
---|
83 | { \ |
---|
84 | if (__s2[__i] > __s1[__i]) actionG; \ |
---|
85 | actionS; \ |
---|
86 | } \ |
---|
87 | if (__s1[__i] > __s2[__i]) actionG; \ |
---|
88 | actionS; \ |
---|
89 | } \ |
---|
90 | while (0) |
---|
91 | |
---|
92 | |
---|
93 | #endif // WORDS_BIGENDIAN |
---|
94 | |
---|
95 | #if defined(PDEBUG) && defined(HAVE_SHIFTED_EXPONENTS) |
---|
96 | extern int pDBsyzComp; |
---|
97 | int rComp0(poly p1, poly p2); |
---|
98 | #else |
---|
99 | inline int rComp0(poly p1, poly p2) |
---|
100 | { |
---|
101 | _prMonCmp(p1, p2, currRing, return 0, return 1, return -1); |
---|
102 | } |
---|
103 | #endif |
---|
104 | |
---|
105 | inline int prComp0(poly p1, poly p2, ring r) |
---|
106 | { |
---|
107 | _prMonCmp(p1, p2, r, return 0, return 1, return -1); |
---|
108 | } |
---|
109 | |
---|
110 | #endif // POLYS_COMP_H |
---|
111 | |
---|