source: git/Singular/polys-comp.h @ 2f7502

fieker-DuValspielwiese
Last change on this file since 2f7502 was 6678d4d, checked in by Hans Schönemann <hannes@…>, 24 years ago
*hannes: type cast added git-svn-id: file:///usr/local/Singular/svn/trunk@4116 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.4 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.19 2000-02-02 18:04:59 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) \
23do                                              \
24{                                               \
25  i = 0;                                        \
26  while (i < l)                                 \
27  {                                             \
28    if (p1[i] != p2[i]) actionD;                \
29    i++;                                        \
30  }                                             \
31  actionE;                                      \
32}                                               \
33while (0)
34
35#define _prMonCmp(p1, p2, r, actionE, actionG, actionS)         \
36do                                                              \
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}                                                               \
53while (0)
54
55#else //  ! WORDS_BIGENDIAN
56
57#define _memcmp(p1, p2, i, actionE, actionD)    \
58do                                              \
59{                                               \
60  for (;;)                                      \
61  {                                             \
62    if (p1[i] != p2[i]) actionD;                \
63    if (i == 0) actionE;                        \
64    i--;                                        \
65  }                                             \
66}                                               \
67while (0)
68
69#define register
70
71#define _prMonCmp(p1, p2, r, actionE, actionG, actionS)             \
72do                                                                  \
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}                                                                   \
90while (0)
91
92
93#endif // WORDS_BIGENDIAN
94
95inline int rComp0(poly p1, poly p2)
96{
97  _prMonCmp(p1, p2, currRing, return 0, return 1, return -1);
98}
99
100inline int prComp0(poly p1, poly p2, ring r)
101{
102  _prMonCmp(p1, p2, r, return 0, return 1, return -1);
103}
104
105#endif // POLYS_COMP_H
106
Note: See TracBrowser for help on using the repository browser.