source: git/kernel/polys-impl.h @ 76e501

spielwiese
Last change on this file since 76e501 was 599326, checked in by Kai Krüger <krueger@…>, 14 years ago
Anne, Kai, Frank: - changes to #include "..." statements to allow cleaner build structure - affected directories: omalloc, kernel, Singular - not yet done: IntergerProgramming git-svn-id: file:///usr/local/Singular/svn/trunk@13032 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.7 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 <kernel/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 pFalseReturn(cond)  do {if (! (cond)) return FALSE;} while (0)
164#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
165#define p_SetRingOfLm(p, r) omSetCustomOfAddr(p, r)
166void p_SetRingOfLeftv(leftv l, ring r);
167#else
168#define p_SetRingOfLm(p, r) ((void)0)
169#define p_SetRingOfLeftv(l, r) ((void)0)
170#endif
171
172#else // ! defined(PDEBUG)
173#define pFalseReturn(cond)           ((void)0)
174#define pAssume(cond)                ((void)0)
175#define pPolyAssume(cond, p,r)      ((void)0)
176#define pPolyAssumeReturn(cond,p,r) ((void)0)
177#define p_SetRingOfLm(p, r)          ((void)0)
178#define p_SetRingOfLeftv(l, r)       ((void)0)
179#endif // defined(PDEBUG)
180
181#if PDEBUG >= 1
182#define pAssume1             pAssume
183#define pPolyAssume1         pPolyAssume
184#define pAssumeReturn1       pAssumeReturn
185#define pPolyAssumeReturn1   pPolyAssumeReturn
186#define _pPolyAssumeReturn1  _pPolyAssumeReturn
187#define p_LmCheckPolyRing1    p_LmCheckPolyRing
188#define p_CheckRing1        p_CheckRing
189#define pIfThen1          pIfThen
190#else
191#define pAssume1(cond)               ((void)0)
192#define pPolyAssume1(cond)           ((void)0)
193#define pAssumeReturn1(cond)         ((void)0)
194#define pPolyAssumeReturn1(cond)     ((void)0)
195#define p_LmCheckPolyRing1(p,r)       ((void)0)
196#define p_CheckRing1(r)             ((void)0)
197#define pIfThen1(cond, check)     ((void)0)
198#endif // PDEBUG >= 1
199
200#if PDEBUG >= 2
201#define pAssume2             pAssume
202#define pPolyAssume2         pPolyAssume
203#define pAssumeReturn2       pAssumeReturn
204#define pPolyAssumeReturn2   pPolyAssumeReturn
205#define p_LmCheckPolyRing2    p_LmCheckPolyRing
206#define p_CheckRing2        p_CheckRing
207#define pIfThen2          pIfThen
208#else
209#define pAssume2(cond)                   ((void)0)
210#define pPolyAssume2(cond,p,r)           ((void)0)
211#define pAssumeReturn2(cond,p,r)         ((void)0)
212#define pPolyAssumeReturn2(cond,p,r)     ((void)0)
213#define p_LmCheckPolyRing2(p,r)          ((void)0)
214#define p_CheckRing2(r)                  ((void)0)
215#define pIfThen2(cond, check)            ((void)0)
216#endif // PDEBUG >= 2
217
218/***************************************************************
219 *
220 * Macros for access/iteration
221 *
222 ***************************************************************/
223
224#define __p_GetComp(p, r)   (p)->exp[r->pCompIndex]
225#define _p_GetComp(p, r)    ((long) (r->pCompIndex >= 0 ? __p_GetComp(p, r) : 0))
226
227/***************************************************************
228 *
229 * Macros for low-level allocation
230 *
231 ***************************************************************/
232#ifdef PDEBUG
233#define p_AllocBin(p, bin, r)                   \
234do                                              \
235{                                               \
236  omTypeAllocBin(poly, p, bin);                 \
237  p_SetRingOfLm(p, r);                        \
238}                                               \
239while (0)
240#define p_FreeBinAddr(p, r) p_LmFree(p, r)
241#else
242#define p_AllocBin(p, bin, r)   omTypeAllocBin(poly, p, bin)
243#define p_FreeBinAddr(p, r)     omFreeBinAddr(p)
244#endif
245
246/***************************************************************
247 *
248 * Misc macros
249 *
250 ***************************************************************/
251#define rRing_has_Comp(r)   (r->pCompIndex >= 0)
252
253// number of Variables
254extern int pVariables;
255
256#endif // POLYS_IMPL_H
Note: See TracBrowser for help on using the repository browser.