source: git/kernel/polys-impl.h @ 8c5988

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