source: git/polys/monomials/polys-impl.h @ a23b21

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