1 | /* Returns TRUE if |
---|
2 | * LM(p) | LM(lcm) |
---|
3 | * LC(p) | LC(lcm) only if ring |
---|
4 | * Exists i, j: |
---|
5 | * LE(p, i) != LE(lcm, i) |
---|
6 | * LE(p1, i) != LE(lcm, i) ==> LCM(p1, p) != lcm |
---|
7 | * LE(p, j) != LE(lcm, j) |
---|
8 | * LE(p2, j) != LE(lcm, j) ==> LCM(p2, p) != lcm |
---|
9 | */ |
---|
10 | BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm) |
---|
11 | { |
---|
12 | int k, j; |
---|
13 | |
---|
14 | if (lcm==NULL) return FALSE; |
---|
15 | |
---|
16 | for (j=(currRing->N); j; j--) |
---|
17 | if ( pGetExp(p,j) > pGetExp(lcm,j)) return FALSE; |
---|
18 | if ( pGetComp(p) != pGetComp(lcm)) return FALSE; |
---|
19 | for (j=(currRing->N); j; j--) |
---|
20 | { |
---|
21 | if (pGetExp(p1,j)!=pGetExp(lcm,j)) |
---|
22 | { |
---|
23 | if (pGetExp(p,j)!=pGetExp(lcm,j)) |
---|
24 | { |
---|
25 | for (k=(currRing->N); k>j; k--) |
---|
26 | { |
---|
27 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
28 | && (pGetExp(p2,k)!=pGetExp(lcm,k))) |
---|
29 | return TRUE; |
---|
30 | } |
---|
31 | for (k=j-1; k; k--) |
---|
32 | { |
---|
33 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
34 | && (pGetExp(p2,k)!=pGetExp(lcm,k))) |
---|
35 | return TRUE; |
---|
36 | } |
---|
37 | return FALSE; |
---|
38 | } |
---|
39 | } |
---|
40 | else if (pGetExp(p2,j)!=pGetExp(lcm,j)) |
---|
41 | { |
---|
42 | if (pGetExp(p,j)!=pGetExp(lcm,j)) |
---|
43 | { |
---|
44 | for (k=(currRing->N); k>j; k--) |
---|
45 | { |
---|
46 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
47 | && (pGetExp(p1,k)!=pGetExp(lcm,k))) |
---|
48 | return TRUE; |
---|
49 | } |
---|
50 | for (k=j-1; k!=0 ; k--) |
---|
51 | { |
---|
52 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
53 | && (pGetExp(p1,k)!=pGetExp(lcm,k))) |
---|
54 | return TRUE; |
---|
55 | } |
---|
56 | return FALSE; |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | return FALSE; |
---|
61 | } |
---|
62 | #ifdef HAVE_RATGRING |
---|
63 | BOOLEAN pCompareChainPart (poly p,poly p1,poly p2,poly lcm) |
---|
64 | { |
---|
65 | int k, j; |
---|
66 | |
---|
67 | if (lcm==NULL) return FALSE; |
---|
68 | |
---|
69 | for (j=currRing->real_var_end; j>=currRing->real_var_start; j--) |
---|
70 | if ( pGetExp(p,j) > pGetExp(lcm,j)) return FALSE; |
---|
71 | if ( pGetComp(p) != pGetComp(lcm)) return FALSE; |
---|
72 | for (j=currRing->real_var_end; j>=currRing->real_var_start; j--) |
---|
73 | { |
---|
74 | if (pGetExp(p1,j)!=pGetExp(lcm,j)) |
---|
75 | { |
---|
76 | if (pGetExp(p,j)!=pGetExp(lcm,j)) |
---|
77 | { |
---|
78 | for (k=(currRing->N); k>j; k--) |
---|
79 | for (k=currRing->real_var_end; k>j; k--) |
---|
80 | { |
---|
81 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
82 | && (pGetExp(p2,k)!=pGetExp(lcm,k))) |
---|
83 | return TRUE; |
---|
84 | } |
---|
85 | for (k=j-1; k>=currRing->real_var_start; k--) |
---|
86 | { |
---|
87 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
88 | && (pGetExp(p2,k)!=pGetExp(lcm,k))) |
---|
89 | return TRUE; |
---|
90 | } |
---|
91 | return FALSE; |
---|
92 | } |
---|
93 | } |
---|
94 | else if (pGetExp(p2,j)!=pGetExp(lcm,j)) |
---|
95 | { |
---|
96 | if (pGetExp(p,j)!=pGetExp(lcm,j)) |
---|
97 | { |
---|
98 | for (k=currRing->real_var_end; k>j; k--) |
---|
99 | { |
---|
100 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
101 | && (pGetExp(p1,k)!=pGetExp(lcm,k))) |
---|
102 | return TRUE; |
---|
103 | } |
---|
104 | for (k=j-1; k>=currRing->real_var_start; k--) |
---|
105 | { |
---|
106 | if ((pGetExp(p,k)!=pGetExp(lcm,k)) |
---|
107 | && (pGetExp(p1,k)!=pGetExp(lcm,k))) |
---|
108 | return TRUE; |
---|
109 | } |
---|
110 | return FALSE; |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | return FALSE; |
---|
115 | } |
---|
116 | #endif |
---|
117 | /*2 |
---|
118 | * returns the length of a (numbers of monomials) |
---|
119 | * respect syzComp |
---|
120 | */ |
---|
121 | poly p_Last(poly a, int &l, const ring r) |
---|
122 | { |
---|
123 | if (a == NULL) |
---|
124 | { |
---|
125 | l = 0; |
---|
126 | return NULL; |
---|
127 | } |
---|
128 | l = 1; |
---|
129 | if (! rIsSyzIndexRing(r)) |
---|
130 | { |
---|
131 | while (pNext(a)!=NULL) |
---|
132 | { |
---|
133 | pIter(a); |
---|
134 | l++; |
---|
135 | } |
---|
136 | } |
---|
137 | else |
---|
138 | { |
---|
139 | int curr_limit = rGetCurrSyzLimit(r); |
---|
140 | poly pp = a; |
---|
141 | while ((a=pNext(a))!=NULL) |
---|
142 | { |
---|
143 | if (p_GetComp(a,r)<=curr_limit/*syzComp*/) |
---|
144 | l++; |
---|
145 | else break; |
---|
146 | pp = a; |
---|
147 | } |
---|
148 | a=pp; |
---|
149 | } |
---|
150 | return a; |
---|
151 | } |
---|