My Project
UNKNOWN_GIT_VERSION
libpolys
polys
monomials
monomials.h
Go to the documentation of this file.
1
#ifndef MONOMIALS_H
2
#define MONOMIALS_H
3
/****************************************
4
* Computer Algebra System SINGULAR *
5
****************************************/
6
/*
7
* ABSTRACT
8
*/
9
10
#include "
omalloc/omalloc.h
"
11
#include "
reporter/reporter.h
"
// for assume etc.
12
#include "
coeffs/coeffs.h
"
// ring,number
13
14
/***************************************************************
15
*
16
* definition of the poly structure and its fields
17
*
18
***************************************************************/
19
20
struct
spolyrec
;
21
typedef
struct
spolyrec
* poly;
22
23
struct
spolyrec
24
{
25
poly
next
;
// next needs to be the first field
26
number
coef
;
// and coef the second --- do not change this !!!
27
unsigned
long
exp
[1];
// make sure that exp is aligned
28
};
29
30
/***************************************************************
31
*
32
* Primitives for accessing and setting fields of a poly
33
* poly must be != NULL
34
*
35
***************************************************************/
36
// next
37
#define pNext(p) ((p)->next)
38
#define pIter(p) (void)((p) = (p)->next)
39
40
// coeff
41
// #define pGetCoeff(p) ((p)->coef)
42
/// return an alias to the leading coefficient of p
43
/// assumes that p != NULL
44
/// NOTE: not copy
45
static
inline
number&
pGetCoeff
(poly
p
)
46
{
47
assume
(
p
!=
NULL
);
48
return
p
->coef;
49
}
50
51
#define p_GetCoeff(p,r) pGetCoeff(p)
52
//static inline number& p_GetCoeff(poly p, const ring r)
53
//{
54
// assume(r != NULL);
55
// return pGetCoeff(p);
56
//}
57
58
59
//
60
#define pSetCoeff0(p,n) (p)->coef=(n)
61
#define p_SetCoeff0(p,n,r) pSetCoeff0(p,n)
62
63
64
#define __p_GetComp(p, r) (p)->exp[r->pCompIndex]
65
#define p_GetComp(p, r) ((long) (r->pCompIndex >= 0 ? __p_GetComp(p, r) : 0))
66
67
68
/***************************************************************
69
*
70
* prepare debugging
71
*
72
***************************************************************/
73
74
#if defined(PDEBUG)
75
76
extern
BOOLEAN
dPolyReportError
(poly
p
, ring r,
const
char
* fmt, ...);
77
78
// macros for checking of polys
79
#define pAssumeReturn(cond) \
80
do \
81
{ \
82
if (! (cond)) \
83
{ \
84
dPolyReportError(NULL, NULL, "pAssume violation of: %s", \
85
#cond); \
86
return FALSE; \
87
} \
88
} \
89
while (0)
90
91
#define pAssume(cond) \
92
do \
93
{ \
94
if (! (cond)) \
95
{ \
96
dPolyReportError(NULL, NULL, "pAssume violation of: %s", \
97
#cond); \
98
} \
99
} \
100
while (0)
101
102
#define _pPolyAssumeReturn(cond, p, r) \
103
do \
104
{ \
105
if (! (cond)) \
106
{ \
107
dPolyReportError(p, r, "pPolyAssume violation of: %s", \
108
#cond); \
109
return FALSE; \
110
} \
111
} \
112
while (0)
113
114
#define _pPolyAssume(cond,p,r) \
115
do \
116
{ \
117
if (! (cond)) \
118
{ \
119
dPolyReportError(p, r, "pPolyAssume violation of: %s", \
120
#cond); \
121
} \
122
} \
123
while (0)
124
125
#define _pPolyAssumeReturnMsg(cond, msg, p, r) \
126
do \
127
{ \
128
if (! (cond)) \
129
{ \
130
dPolyReportError(p, r, "%s ", msg); \
131
return FALSE; \
132
} \
133
} \
134
while (0)
135
136
#define pPolyAssume(cond) _pPolyAssume(cond, p, r)
137
#define pPolyAssumeReturn(cond) _pPolyAssumeReturn(cond, p, r)
138
#define pPolyAssumeReturnMsg(cond, msg) _pPolyAssumeReturnMsg(cond, msg, p, r)
139
140
#define pFalseReturn(cond) do {if (! (cond)) return FALSE;} while (0)
141
#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
142
#define p_SetRingOfLm(p, r) omSetCustomOfAddr(p, r)
143
//void p_SetRingOfLeftv(leftv l, ring r);
144
#else
145
#define p_SetRingOfLm(p, r) do {} while (0)
146
//#define p_SetRingOfLeftv(l, r) do {} while (0)
147
#endif
148
149
#else // ! defined(PDEBUG)
150
#define pFalseReturn(cond) do {} while (0)
151
#define pAssume(cond) do {} while (0)
152
#define pPolyAssume(cond) do {} while (0)
153
#define _pPolyAssume(cond, p,r) do {} while (0)
154
#define pAssumeReturn(cond) do {} while (0)
155
#define pPolyAssumeReturn(cond) do {} while (0)
156
#define _pPolyAssumeReturn(cond,p,r) do {} while (0)
157
#define p_SetRingOfLm(p, r) do {} while (0)
158
//#define p_SetRingOfLeftv(l, r) do {} while (0)
159
#endif // defined(PDEBUG)
160
161
#if PDEBUG >= 1
162
#define pAssume1 pAssume
163
#define pPolyAssume1 pPolyAssume
164
#define _pPolyAssume1 _pPolyAssume
165
#define pAssumeReturn1 pAssumeReturn
166
#define pPolyAssumeReturn1 pPolyAssumeReturn
167
#define _pPolyAssumeReturn1 _pPolyAssumeReturn
168
#define p_LmCheckPolyRing1 p_LmCheckPolyRing
169
#define p_CheckRing1 p_CheckRing
170
#define pIfThen1 pIfThen
171
#else
172
#define pAssume1(cond) do {} while (0)
173
#define pPolyAssume1(cond) do {} while (0)
174
#define _pPolyAssume1(cond,p,r) do {} while (0)
175
#define pAssumeReturn1(cond) do {} while (0)
176
#define pPolyAssumeReturn1(cond) do {} while (0)
177
#define _pPolyAssumeReturn1(cond,p,r)do {} while (0)
178
#define p_LmCheckPolyRing1(p,r) do {} while (0)
179
#define p_CheckRing1(r) do {} while (0)
180
#define pIfThen1(cond, check) do {} while (0)
181
#endif // PDEBUG >= 1
182
183
#if PDEBUG >= 2
184
#define pAssume2 pAssume
185
#define pPolyAssume2 pPolyAssume
186
#define _pPolyAssume2 _pPolyAssume
187
#define pAssumeReturn2 pAssumeReturn
188
#define pPolyAssumeReturn2 pPolyAssumeReturn
189
#define _pPolyAssumeReturn2 _pPolyAssumeReturn
190
#define p_LmCheckPolyRing2 p_LmCheckPolyRing
191
#define p_CheckRing2 p_CheckRing
192
#define pIfThen2 pIfThen
193
#else
194
#define pAssume2(cond) do {} while (0)
195
#define pPolyAssume2(cond) do {} while (0)
196
#define _pPolyAssume2(cond,p,r) do {} while (0)
197
#define pAssumeReturn2(cond) do {} while (0)
198
#define pPolyAssumeReturn2(cond) do {} while (0)
199
#define _pPolyAssumeReturn2(cond,p,r)do {} while (0)
200
#define p_LmCheckPolyRing2(p,r) do {} while (0)
201
#define p_CheckRing2(r) do {} while (0)
202
#define pIfThen2(cond, check) do {} while (0)
203
#endif // PDEBUG >= 2
204
205
/***************************************************************
206
*
207
* Macros for low-level allocation
208
*
209
***************************************************************/
210
#ifdef PDEBUG
211
#define p_AllocBin(p, bin, r) \
212
do \
213
{ \
214
omTypeAllocBin(poly, p, bin); \
215
p_SetRingOfLm(p, r); \
216
} \
217
while (0)
218
#define p_FreeBinAddr(p, r) p_LmFree(p, r)
219
#else
220
#define p_AllocBin(p, bin, r) omTypeAllocBin(poly, p, bin)
221
#define p_FreeBinAddr(p, r) omFreeBinAddr(p)
222
#endif
223
224
/***************************************************************
225
*
226
* Purpose: low-level and macro definition of polys
227
*
228
* If you touch anything here, you better know what you are doing.
229
* What is here should not be used directly from other routines -- the
230
* encapsulations in polys.h should be used, instead.
231
*
232
***************************************************************/
233
234
#define POLYSIZE (sizeof(poly) + sizeof(number))
235
#define POLYSIZEW (POLYSIZE / sizeof(long))
236
#if SIZEOF_LONG == 8
237
#define POLY_NEGWEIGHT_OFFSET (((long)0x80000000) << 32)
238
#else
239
#define POLY_NEGWEIGHT_OFFSET ((long)0x80000000)
240
#endif
241
242
243
/***************************************************************
244
*
245
* Macros for low-level allocation
246
*
247
***************************************************************/
248
#ifdef PDEBUG
249
#define p_AllocBin(p, bin, r) \
250
do \
251
{ \
252
omTypeAllocBin(poly, p, bin); \
253
p_SetRingOfLm(p, r); \
254
} \
255
while (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
#endif
omalloc.h
dPolyReportError
BOOLEAN dPolyReportError(poly p, ring r, const char *fmt,...)
Definition:
pDebug.cc:44
reporter.h
spolyrec::next
poly next
Definition:
monomials.h:25
BOOLEAN
int BOOLEAN
Definition:
auxiliary.h:85
spolyrec
Definition:
monomials.h:24
spolyrec::coef
number coef
Definition:
monomials.h:26
assume
#define assume(x)
Definition:
mod2.h:390
NULL
#define NULL
Definition:
omList.c:10
p
int p
Definition:
cfModGcd.cc:4019
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition:
monomials.h:45
spolyrec::exp
unsigned long exp[1]
Definition:
monomials.h:27
coeffs.h
Coefficient rings, fields and other domains suitable for Singular polynomials.
Generated on Wed Sep 30 2020 00:00:00 for My Project by
doxygen 1.8.20
for
Singular UNKNOWN_GIT_VERSION