source: git/Singular/polys-comp.h @ 64eef3

fieker-DuValspielwiese
Last change on this file since 64eef3 was 847242, checked in by Imade Sulandra <sulandra@…>, 24 years ago
*** empty log message *** git-svn-id: file:///usr/local/Singular/svn/trunk@4573 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.2 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.25 2000-09-07 13:39:44 sulandra 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
18#ifndef HAVE_SHIFTED_EXPONENTS
19
20// need to undefine this, since longs might be negative
21#define u_s
22
23#ifdef WORDS_BIGENDIAN
24
25#define _memcmp(p1, p2, i, l, actionE, actionD) \
26do                                              \
27{                                               \
28  i = 0;                                        \
29  while (i < l)                                 \
30  {                                             \
31    if (p1[i] != p2[i]) actionD;                \
32    i++;                                        \
33  }                                             \
34  actionE;                                      \
35}                                               \
36while (0)
37
38#define _prMonCmp(p1, p2, r, actionE, actionG, actionS)         \
39do                                                              \
40{                                                               \
41  register const u_s long* s1 = &(p1->exp.l[r->pCompLowIndex]); \
42  register const u_s long* s2 = &(p2->exp.l[r->pCompLowIndex]); \
43  int _l = r->pCompLSize;                                       \
44  register int _i;                                              \
45  _memcmp(s1, s2, _i, _l, actionE, goto _NotEqual);             \
46                                                                \
47  _NotEqual:                                                    \
48  if (r->ordsgn[_i] != 1)                                       \
49  {                                                             \
50    if (s2[_i] > s1[_i]) actionG;                               \
51    actionS;                                                    \
52  }                                                             \
53  if (s1[_i] > s2[_i]) actionG;                                 \
54  actionS;                                                      \
55}                                                               \
56while (0)
57
58#else //  ! WORDS_BIGENDIAN
59
60#define _memcmp(p1, p2, i, actionE, actionD)    \
61do                                              \
62{                                               \
63  for (;;)                                      \
64  {                                             \
65    if (p1[i] != p2[i]) actionD;                \
66    if (i == 0) actionE;                        \
67    i--;                                        \
68  }                                             \
69}                                               \
70while (0)
71
72#define register
73
74#define _prMonCmp(p1, p2, r, actionE, actionG, actionS)             \
75do                                                                  \
76{                                                                   \
77  register const u_s long* __s1 =                                   \
78                    (const long *)&(p1->exp.l[r->pCompLowIndex]);   \
79  register const u_s long* __s2 =                                   \
80                    (const long *)&(p2->exp.l[r->pCompLowIndex]);   \
81  register int __i = r->pCompLSize - 1;                             \
82  _memcmp(__s1, __s2, __i, actionE, goto _NotEqual);                \
83                                                                    \
84  _NotEqual:                                                        \
85  if (r->ordsgn[__i] != 1)                                          \
86  {                                                                 \
87    if (__s2[__i] > __s1[__i]) actionG;                             \
88    actionS;                                                        \
89  }                                                                 \
90  if (__s1[__i] > __s2[__i]) actionG;                               \
91  actionS;                                                          \
92}                                                                   \
93while (0)
94
95
96#endif // WORDS_BIGENDIAN
97#else // ndef HAVE_SHIFTED_EXPONENTS
98
99// copied from BIGENDIAN case, with modification: pCompLowIndex=0
100
101// need to undefine this, since longs might be negative
102#define u_s unsigned
103
104#define _memcmp(p1, p2, i, l, actionE, actionD) \
105do                                              \
106{                                               \
107  i = 0;                                        \
108  while (i < l)                                 \
109  {                                             \
110    if (p1[i] != p2[i]) actionD;                \
111    i++;                                        \
112  }                                             \
113  actionE;                                      \
114}                                               \
115while (0)
116
117#define _prMonCmp(p1, p2, r, actionE, actionG, actionS)   \
118do                                                        \
119{                                                         \
120  register const u_s long* s1 = &(p1->exp.l[0]);          \
121  register const u_s long* s2 = &(p2->exp.l[0]);          \
122  int _l = r->pCompLSize;                                 \
123  register int _i;                                        \
124  _memcmp(s1, s2, _i, _l, actionE, goto _NotEqual);       \
125                                                          \
126  _NotEqual:                                              \
127  if (r->ordsgn[_i] != 1)                                 \
128  {                                                       \
129    if (s2[_i] > s1[_i]) actionG;                         \
130    actionS;                                              \
131  }                                                       \
132  if (s1[_i] > s2[_i]) actionG;                           \
133  actionS;                                                \
134}                                                         \
135while (0)
136
137#endif
138
139inline int rComp0(poly p1, poly p2)
140{
141  _prMonCmp(p1, p2, currRing, return 0, return 1, return -1);
142}
143
144inline int prComp0(poly p1, poly p2, ring r)
145{
146  _prMonCmp(p1, p2, r, return 0, return 1, return -1);
147}
148
149#endif // POLYS_COMP_H
150
Note: See TracBrowser for help on using the repository browser.