source: git/Singular/polys-comp.h @ 5480da

spielwiese
Last change on this file since 5480da was 8fc5558, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* added spSpolyLoop.pl to repository git-svn-id: file:///usr/local/Singular/svn/trunk@1239 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 20.7 KB
Line 
1#ifndef POLYS_COMP_H
2#define POLYS_COMP_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: polys-comp.h,v 1.6 1998-03-17 10:59:56 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)  \
20do                                                          \
21{                                                           \
22  d = *((long*) &(p1->exp[0])) - *((long*) &(p2->exp[0]));  \
23  if (d) actionD;                                           \
24  actionE;                                                  \
25}                                                           \
26while(0)
27 
28#define _pMonComp_otEXPCOMP_nwONE(p1, p2, d, actionD, actionE)  \
29do                                                              \
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}                                                               \
40while(0)
41
42#define _pMonComp_otEXP_nwTWO(p1, p2, d, actionD, actionE)  \
43do                                                          \
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}                                                           \
53while(0)
54 
55#define _pMonComp_otEXPCOMP_nwTWO(p1, p2, d, actionD, actionE)  \
56do                                                              \
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}                                                               \
71while(0)
72 
73#define _pMonComp_otEXP_nwEVEN(p1, p2, length, d, actionD, actionE) \
74do                                                                  \
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}                                                                   \
93while(0)
94
95#define _pMonComp_otEXP_nwODD(p1, p2, length, d, actionD, actionE)  \
96do                                                                  \
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}                                                                   \
115while(0)
116 
117#define _pMonComp_otEXPCOMP_nwEVEN(p1, p2, length, d, actionD, actionE) \
118do                                                                      \
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}                                                                       \
146while(0)
147 
148#define _pMonComp_otEXPCOMP_nwODD(p1, p2, length, d, actionD, actionE)  \
149do                                                                      \
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}                                                                       \
177while(0)
178
179#else //  ! WORDS_BIGENDIAN
180
181#define _pMonComp_otEXP_nwONE(p1, p2, d, actionD, actionE)                  \
182do                                                                          \
183{                                                                           \
184  d = *(((long*) p1) + pMonomSizeW-1) - *(((long*) p2)  + pMonomSizeW-1);   \
185  if (d) actionD;                                                           \
186  actionE;                                                                  \
187}                                                                           \
188while(0)
189 
190#define _pMonComp_otEXPCOMP_nwONE(p1, p2, d, actionD, actionE)              \
191do                                                                          \
192{                                                                           \
193  d = *(((long*) p1) + pMonomSizeW-1) - *(((long*) p2)  + pMonomSizeW-1);   \
194  if (d)                                                                    \
195  {                                                                         \
196    if (((long) (pGetComp(p1) - pGetComp(p2))) == d)                        \
197      d = -d;                                                               \
198    actionD;                                                                \
199  }                                                                         \
200  actionE;                                                                  \
201}                                                                           \
202while(0)
203
204#define _pMonComp_otEXP_nwTWO(p1, p2, d, actionD, actionE)  \
205do                                                          \
206{                                                           \
207  const long* s1 = ((long*) p1) + pMonomSizeW-1;            \
208  const long* s2 = ((long*) p2)  + pMonomSizeW-1;           \
209  d = *s1 - *s2;                                            \
210  if (d) actionD;                                           \
211  d = *(s1 - 1) - *(s2 - 1);                                \
212  if (d) actionD;                                           \
213  actionE;                                                  \
214}                                                           \
215while(0)
216 
217#define _pMonComp_otEXPCOMP_nwTWO(p1, p2, d, actionD, actionE)  \
218do                                                              \
219{                                                               \
220  const long* s1 = ((long*) p1) + pMonomSizeW-1;                \
221  const long* s2 = ((long*) p2)  + pMonomSizeW-1;               \
222  d = *s1 - *s2;                                                \
223  if (d) actionD;                                               \
224  d = *s1 - *s2;                                                \
225  if (d) actionD;                                               \
226  d = *(s1 -1) - *(s2 -1);                                      \
227  if (d)                                                        \
228  {                                                             \
229    if (((long) (pGetComp(p1) - pGetComp(p2))) == d)            \
230      d = -d;                                                   \
231    actionD;                                                    \
232  }                                                             \
233  actionE;                                                      \
234}                                                               \
235while(0)
236 
237#define _pMonComp_otEXP_nwEVEN(p1, p2, length, d, actionD, actionE) \
238do                                                                  \
239{                                                                   \
240  const long* s1 = ((long*) p1) + pMonomSizeW-1;                    \
241  const long* s2 = ((long*) p2)  + pMonomSizeW-1;                   \
242  const long* const lb = s1 - length;                               \
243  for (;;)                                                          \
244  {                                                                 \
245    d = *s1 - *s2;                                                  \
246    if (d) actionD;                                                 \
247    s1--;                                                           \
248    s2--;                                                           \
249    d = *s1 - *s2;                                                  \
250    if (d) actionD;                                                 \
251    s1--;                                                           \
252    if (s1 == lb) actionE;                                          \
253    s2--;                                                           \
254  }                                                                 \
255}                                                                   \
256while(0)
257
258#define _pMonComp_otEXP_nwODD(p1, p2, length, d, actionD, actionE)  \
259do                                                                  \
260{                                                                   \
261  const long* s1 = ((long*) p1) + pMonomSizeW-1;                    \
262  const long* s2 = ((long*) p2)  + pMonomSizeW-1;                   \
263  const long* const lb = s1 - length;                               \
264                                                                    \
265  for (;;)                                                          \
266  {                                                                 \
267    d = *s1 - *s2;                                                  \
268    if (d) actionD;                                                 \
269    s1--;                                                           \
270    if (s1 == lb) actionE;                                          \
271    s2--;                                                           \
272    d = *s1 - *s2;                                                  \
273    if (d) actionD;                                                 \
274    s1--;                                                           \
275    s2--;                                                           \
276  }                                                                 \
277}                                                                   \
278while(0)
279 
280#define _pMonComp_otEXPCOMP_nwEVEN(p1, p2, length, d, actionD, actionE) \
281do                                                                      \
282{                                                                       \
283  const long* s1 = ((long*) p1) + pMonomSizeW-1;                        \
284  const long* s2 = ((long*) p2)  + pMonomSizeW-1;                       \
285  const long* const lb = s1 - length +1;                                \
286                                                                        \
287  for (;;)                                                              \
288  {                                                                     \
289    d = *s1 - *s2;                                                      \
290    if (d) actionD;                                                     \
291    s1--;                                                               \
292    if (s1 == lb) break;                                                \
293    s2--;                                                               \
294    d = *s1 - *s2;                                                      \
295    if (d) actionD;                                                     \
296    s1--;                                                               \
297    s2--;                                                               \
298  }                                                                     \
299                                                                        \
300  d = *s1 - *(s2 - 1);                                                  \
301  if (d)                                                                \
302  {                                                                     \
303    if (((long) (pGetComp(p1) - pGetComp(p2))) == d)                    \
304      d = -d;                                                           \
305    actionD;                                                            \
306  }                                                                     \
307  actionE;                                                              \
308}                                                                       \
309while(0)
310 
311#define _pMonComp_otEXPCOMP_nwODD(p1, p2, length, d, actionD, actionE)  \
312do                                                                      \
313{                                                                       \
314  const long* s1 = ((long*) p1) + pMonomSizeW-1;                        \
315  const long* s2 = ((long*) p2)  + pMonomSizeW-1;                       \
316  const long* const lb = s1 - length +1;                                \
317                                                                        \
318  for (;;)                                                              \
319  {                                                                     \
320    d = *s1 - *s2;                                                      \
321    if (d) actionD;                                                     \
322    s1--;                                                               \
323    s2--;                                                               \
324    d = *s1 - *s2;                                                      \
325    if (d) actionD;                                                     \
326    s1--;                                                               \
327    if (s1 == lb) break;                                                \
328    s2--;                                                               \
329  }                                                                     \
330                                                                        \
331  d = *s1 - *(s2 - 1);                                                  \
332  if (d)                                                                \
333  {                                                                     \
334    if (((long) (pGetComp(p1) - pGetComp(p2))) == d)                    \
335      d = -d;                                                           \
336    actionD;                                                            \
337  }                                                                     \
338  actionE;                                                              \
339}                                                                       \
340while(0)
341
342#endif // WORDS_BIGENDIAN
343
344#endif // POLYS_COMP_H
345
Note: See TracBrowser for help on using the repository browser.