source: git/kernel/polys-impl.h @ 40ef69

fieker-DuValspielwiese
Last change on this file since 40ef69 was 0b5e3d, checked in by Hans Schönemann <hannes@…>, 14 years ago
Exponent_t removed git-svn-id: file:///usr/local/Singular/svn/trunk@12664 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.5 KB
Line 
1#ifndef POLYS_IMPL_H
2#define POLYS_IMPL_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7
8/***************************************************************
9 *
10 * File:       polys-impl.h
11 * Purpose:    low-level and macro definition of polys
12 *
13 * If you touch anything here, you better know what you are doing.
14 * What is here should not be used directly from other routines -- the
15 * encapsulations in polys.h should be used, instead.
16 *
17 ***************************************************************/
18#include "structs.h"
19#include "omalloc.h"
20
21/***************************************************************
22 *
23 * definition of the poly structure and its fields
24 *
25 ***************************************************************/
26
27#ifndef NDEBUG
28#define VARS (10)   /*max. number of variables as constant*/
29#else
30#ifdef __GNUC__
31#define VARS (0)
32#else
33#define VARS (1)
34#endif
35#endif
36
37struct  spolyrec
38{
39  poly      next;           // next needs to be the first field
40  number    coef;           // and coef the second --- do not change this !!!
41  unsigned long exp[VARS];  // make sure that exp is aligned
42};
43#define POLYSIZE (sizeof(poly) + sizeof(number))
44#define POLYSIZEW (POLYSIZE / sizeof(long))
45#if SIZEOF_LONG == 8
46#define POLY_NEGWEIGHT_OFFSET (((long)0x80000000) << 32)
47#else
48#define POLY_NEGWEIGHT_OFFSET ((long)0x80000000)
49#endif
50
51
52/***************************************************************
53 *
54 * What should be inlined and debugged?
55 *
56 ***************************************************************/
57#ifdef NO_PDEBUG
58#undef PDEBUG
59#endif
60
61// determines inlining of poly procs which iter through polys
62#if defined(DO_PINLINE0) && !defined(PDEBUG)
63#define PINLINE0 static inline
64#else
65#define PINLINE0
66#endif
67
68// determines inlining of poly procs which iter over ExpVector
69#undef NO_PINLINE1
70#if PDEBUG <= 0 && !defined(NO_INLINE1)
71#define PINLINE1 static inline
72#else
73#define PINLINE1
74#define NO_PINLINE1 1
75#endif
76
77// determines inlining of constant time poly procs
78#undef NO_PINLINE2
79#if PDEBUG <= 1 && !defined(NO_INLINE2)
80#define PINLINE2 static inline
81#else
82#define PINLINE2
83#define NO_PINLINE2 1
84#endif
85
86// determines inlining of stuff from polys-impl.h
87#undef NO_PINLINE3
88#if PDEBUG <= 2 && !defined(NO_INLINE3)
89#define PINLINE3 static inline
90#else
91#define PINLINE3
92#define NO_PINLINE3 1
93#endif
94
95/***************************************************************
96 *
97 * prepare debugging
98 *
99 ***************************************************************/
100
101#if defined(PDEBUG)
102
103extern BOOLEAN dPolyReportError(poly p, ring r, const char* fmt, ...);
104
105// macros for checking of polys
106#define pAssumeReturn(cond)                                  \
107do                                                          \
108{                                                           \
109  if (! (cond))                                             \
110  {                                                         \
111    dPolyReportError(NULL, NULL, "pAssume violation of: %s", \
112                 #cond);                                    \
113    return FALSE;                                           \
114  }                                                         \
115}                                                           \
116while (0)
117
118#define pAssume(cond)                                        \
119do                                                          \
120{                                                           \
121  if (! (cond))                                             \
122  {                                                         \
123    dPolyReportError(NULL, NULL, "pAssume violation of: %s", \
124                 #cond);                                    \
125  }                                                         \
126}                                                           \
127while (0)
128
129#define _pPolyAssumeReturn(cond, p, r)                       \
130do                                                          \
131{                                                           \
132  if (! (cond))                                             \
133  {                                                         \
134    dPolyReportError(p, r, "pPolyAssume violation of: %s",   \
135                 #cond);                                    \
136    return FALSE;                                           \
137  }                                                         \
138}                                                           \
139while (0)
140
141#define _pPolyAssume(cond,p,r)                                   \
142do                                                              \
143{                                                               \
144  if (! (cond))                                                 \
145  {                                                             \
146    dPolyReportError(p, r, "pPolyAssume violation of: %s",    \
147                 #cond);                                        \
148  }                                                             \
149}                                                               \
150while (0)
151
152#define _pPolyAssumeReturnMsg(cond, msg, p, r)   \
153do                                              \
154{                                               \
155  if (! (cond))                                 \
156  {                                             \
157    dPolyReportError(p, r, "%s ",  msg);        \
158    return FALSE;                               \
159  }                                             \
160}                                               \
161while (0)
162
163#define pPolyAssume(cond)        _pPolyAssume(cond, p, r)
164#define pPolyAssumeReturn(cond)  _pPolyAssumeReturn(cond, p, r)
165#define pPolyAssumeReturnMsg(cond, msg)  _pPolyAssumeReturnMsg(cond, msg, p, r)
166
167#define pFalseReturn(cond)  do {if (! (cond)) return FALSE;} while (0)
168#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
169#define p_SetRingOfLm(p, r) omSetCustomOfAddr(p, r)
170void p_SetRingOfLeftv(leftv l, ring r);
171#else
172#define p_SetRingOfLm(p, r) ((void)0)
173#define p_SetRingOfLeftv(l, r) ((void)0)
174#endif
175
176#else // ! defined(PDEBUG)
177#define pFalseReturn(cond)           ((void)0)
178#define pAssume(cond)                ((void)0)
179#define pPolyAssume(cond)            ((void)0)
180#define _pPolyAssume(cond, p,r)      ((void)0)
181#define pAssumeReturn(cond)          ((void)0)
182#define pPolyAssumeReturn(cond)      ((void)0)
183#define _pPolyAssumeReturn(cond,p,r) ((void)0)
184#define p_SetRingOfLm(p, r)          ((void)0)
185#define p_SetRingOfLeftv(l, r)       ((void)0)
186#endif // defined(PDEBUG)
187
188#if PDEBUG >= 1
189#define pAssume1             pAssume
190#define pPolyAssume1         pPolyAssume
191#define _pPolyAssume1        _pPolyAssume
192#define pAssumeReturn1       pAssumeReturn
193#define pPolyAssumeReturn1   pPolyAssumeReturn
194#define _pPolyAssumeReturn1  _pPolyAssumeReturn
195#define p_LmCheckPolyRing1    p_LmCheckPolyRing
196#define p_CheckRing1        p_CheckRing
197#define pIfThen1          pIfThen
198#else
199#define pAssume1(cond)               ((void)0)
200#define pPolyAssume1(cond)           ((void)0)
201#define _pPolyAssume1(cond,p,r)      ((void)0)
202#define pAssumeReturn1(cond)         ((void)0)
203#define pPolyAssumeReturn1(cond)     ((void)0)
204#define _pPolyAssumeReturn1(cond,p,r)((void)0)
205#define p_LmCheckPolyRing1(p,r)       ((void)0)
206#define p_CheckRing1(r)             ((void)0)
207#define pIfThen1(cond, check)     ((void)0)
208#endif // PDEBUG >= 1
209
210#if PDEBUG >= 2
211#define pAssume2             pAssume
212#define pPolyAssume2         pPolyAssume
213#define _pPolyAssume2        _pPolyAssume
214#define pAssumeReturn2       pAssumeReturn
215#define pPolyAssumeReturn2   pPolyAssumeReturn
216#define _pPolyAssumeReturn2  _pPolyAssumeReturn
217#define p_LmCheckPolyRing2    p_LmCheckPolyRing
218#define p_CheckRing2        p_CheckRing
219#define pIfThen2          pIfThen
220#else
221#define pAssume2(cond)               ((void)0)
222#define pPolyAssume2(cond)           ((void)0)
223#define _pPolyAssume2(cond,p,r)      ((void)0)
224#define pAssumeReturn2(cond)         ((void)0)
225#define pPolyAssumeReturn2(cond)     ((void)0)
226#define _pPolyAssumeReturn2(cond,p,r)((void)0)
227#define p_LmCheckPolyRing2(p,r)       ((void)0)
228#define p_CheckRing2(r)             ((void)0)
229#define pIfThen2(cond, check)     ((void)0)
230#endif // PDEBUG >= 2
231
232/***************************************************************
233 *
234 * Macros for access/iteration
235 *
236 ***************************************************************/
237#define _pNext(p)           ((p)->next)
238#define _pIter(p)           ((p) = (p)->next)
239
240// coeff
241#define _pGetCoeff(p)       ((p)->coef)
242#define _pSetCoeff0(p,n)    (p)->coef=n
243#define __p_GetComp(p, r)   (p)->exp[r->pCompIndex]
244#define _p_GetComp(p, r)    ((long) (r->pCompIndex >= 0 ? __p_GetComp(p, r) : 0))
245
246/***************************************************************
247 *
248 * Macros for low-level allocation
249 *
250 ***************************************************************/
251#ifdef PDEBUG
252#define p_AllocBin(p, bin, r)                   \
253do                                              \
254{                                               \
255  omTypeAllocBin(poly, p, bin);                 \
256  p_SetRingOfLm(p, r);                        \
257}                                               \
258while (0)
259#define p_FreeBinAddr(p, r) p_LmFree(p, r)
260#else
261#define p_AllocBin(p, bin, r)   omTypeAllocBin(poly, p, bin)
262#define p_FreeBinAddr(p, r)     omFreeBinAddr(p)
263#endif
264
265/***************************************************************
266 *
267 * Misc macros
268 *
269 ***************************************************************/
270#define rRing_has_Comp(r)   (r->pCompIndex >= 0)
271
272// number of Variables
273extern int pVariables;
274
275#endif // POLYS_IMPL_H
Note: See TracBrowser for help on using the repository browser.