source: git/Singular/polys-impl.h @ a5189b

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