My Project
Loading...
Searching...
No Matches
Functions
polys0.cc File Reference
#include "misc/auxiliary.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/shiftop.h"

Go to the source code of this file.

Functions

static void writemon (poly p, int ko, const ring r)
 
static void writemonLP (poly p, int ko, const ring r)
 
void p_String0Short (const poly p, ring lmRing, ring tailRing)
 if possible print p in a short way... More...
 
void p_String0Long (const poly p, ring lmRing, ring tailRing)
 print p in a long way... More...
 
void p_String0 (poly p, ring lmRing, ring tailRing)
 print p according to ShortOut in lmRing & tailRing More...
 
char * p_String (poly p, ring lmRing, ring tailRing)
 
void p_Write0 (poly p, ring lmRing, ring tailRing)
 
void p_Write (poly p, ring lmRing, ring tailRing)
 
void p_wrp0 (poly p, ring ri)
 
void p_wrp (poly p, ring lmRing, ring tailRing)
 

Function Documentation

◆ p_String()

char * p_String ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 322 of file polys0.cc.

323{
324 StringSetS("");
325 p_String0(p, lmRing, tailRing);
326 return StringEndS();
327}
int p
Definition: cfModGcd.cc:4078
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:223
void StringSetS(const char *st)
Definition: reporter.cc:128
char * StringEndS()
Definition: reporter.cc:151

◆ p_String0()

void p_String0 ( poly  p,
ring  lmRing,
ring  tailRing 
)

print p according to ShortOut in lmRing & tailRing

Definition at line 223 of file polys0.cc.

224{
225 if (p == NULL)
226 {
227 StringAppendS("0");
228 return;
229 }
230 p_Normalize(p,lmRing);
231 if ((n_GetChar(lmRing->cf) == 0)
232 && (nCoeff_is_transExt(lmRing->cf)))
233 p_Normalize(p,lmRing); /* Manual/absfact.tst */
234#ifdef HAVE_SHIFTBBA
235 if(lmRing->isLPring)
236 {
237 if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
238 {
239 writemonLP(p,0, lmRing);
240 p = pNext(p);
241 while (p!=NULL)
242 {
243 assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
244 if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
245 StringAppendS("+");
246 writemonLP(p,0, tailRing);
247 p = pNext(p);
248 }
249 return;
250 }
251 }
252 else
253#endif
254 {
255 if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
256 {
257 writemon(p,0, lmRing);
258 p = pNext(p);
259 while (p!=NULL)
260 {
261 assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
262 if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
263 StringAppendS("+");
264 writemon(p,0, tailRing);
265 p = pNext(p);
266 }
267 return;
268 }
269 }
270
271 long k = 1;
272 StringAppendS("[");
273#ifdef HAVE_SHIFTBBA
274 if(lmRing->isLPring)
275 {
276 loop
277 {
278 while (k < p_GetComp(p,lmRing))
279 {
280 StringAppendS("0,");
281 k++;
282 }
283 writemonLP(p,k,lmRing);
284 pIter(p);
285 while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
286 {
287 if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
288 writemonLP(p,k,tailRing);
289 pIter(p);
290 }
291 if (p == NULL) break;
292 StringAppendS(",");
293 k++;
294 }
295 }
296 else
297#endif
298 {
299 loop
300 {
301 while (k < p_GetComp(p,lmRing))
302 {
303 StringAppendS("0,");
304 k++;
305 }
306 writemon(p,k,lmRing);
307 pIter(p);
308 while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
309 {
310 if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
311 writemon(p,k,tailRing);
312 pIter(p);
313 }
314 if (p == NULL) break;
315 StringAppendS(",");
316 k++;
317 }
318 }
319 StringAppendS("]");
320}
int k
Definition: cfEzgcd.cc:99
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition: coeffs.h:491
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:461
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:441
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:915
#define assume(x)
Definition: mod2.h:389
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
#define pNext(p)
Definition: monomials.h:36
#define NULL
Definition: omList.c:12
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3813
static void writemon(poly p, int ko, const ring r)
Definition: polys0.cc:24
static void writemonLP(poly p, int ko, const ring r)
Definition: polys0.cc:104
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define loop
Definition: structs.h:75

◆ p_String0Long()

void p_String0Long ( const poly  p,
ring  lmRing,
ring  tailRing 
)

print p in a long way...

print p in a long way

Definition at line 203 of file polys0.cc.

204{
205 // NOTE: the following (non-thread-safe!) UGLYNESS
206 // (changing naRing->ShortOut for a while) is due to Hans!
207 // Just think of other ring using the VERY SAME naRing and possible
208 // side-effects...
209 // but this is not a problem: i/o is not thread-safe anyway.
210 const BOOLEAN bLMShortOut = rShortOut(lmRing);
211 const BOOLEAN bTAILShortOut = rShortOut(tailRing);
212
213 lmRing->ShortOut = FALSE;
214 tailRing->ShortOut = FALSE;
215
216 p_String0(p, lmRing, tailRing);
217
218 lmRing->ShortOut = bLMShortOut;
219 tailRing->ShortOut = bTAILShortOut;
220}
int BOOLEAN
Definition: auxiliary.h:87
#define FALSE
Definition: auxiliary.h:96
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:581

◆ p_String0Short()

void p_String0Short ( const poly  p,
ring  lmRing,
ring  tailRing 
)

if possible print p in a short way...

print p in a short way, if possible

Definition at line 184 of file polys0.cc.

185{
186 // NOTE: the following (non-thread-safe!) UGLYNESS
187 // (changing naRing->ShortOut for a while) is due to Hans!
188 // Just think of other ring using the VERY SAME naRing and possible
189 // side-effects...
190 const BOOLEAN bLMShortOut = rShortOut(lmRing);
191 const BOOLEAN bTAILShortOut = rShortOut(tailRing);
192
193 lmRing->ShortOut = rCanShortOut(lmRing);
194 tailRing->ShortOut = rCanShortOut(tailRing);
195
196 p_String0(p, lmRing, tailRing);
197
198 lmRing->ShortOut = bLMShortOut;
199 tailRing->ShortOut = bTAILShortOut;
200}
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:586

◆ p_Write()

void p_Write ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 342 of file polys0.cc.

343{
344 p_Write0(p, lmRing, tailRing);
345 PrintLn();
346}
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:332
void PrintLn()
Definition: reporter.cc:310

◆ p_Write0()

void p_Write0 ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 332 of file polys0.cc.

333{
334 char *s=p_String(p, lmRing, tailRing);
335 PrintS(s);
336 omFree(s);
337}
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define omFree(addr)
Definition: omAllocDecl.h:261
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:322
void PrintS(const char *s)
Definition: reporter.cc:284

◆ p_wrp()

void p_wrp ( poly  p,
ring  lmRing,
ring  tailRing 
)

Definition at line 373 of file polys0.cc.

374{
375 poly r;
376
377 if (p==NULL) PrintS("NULL");
378 else if (pNext(p)==NULL) p_Write0(p, lmRing);
379 else
380 {
381 r = pNext(pNext(p));
382 pNext(pNext(p)) = NULL;
383 p_Write0(p, tailRing);
384 if (r!=NULL)
385 {
386 PrintS("+...");
387 pNext(pNext(p)) = r;
388 }
389 }
390}

◆ p_wrp0()

void p_wrp0 ( poly  p,
ring  ri 
)

Definition at line 354 of file polys0.cc.

355{
356 poly r;
357
358 if (p==NULL) PrintS("NULL");
359 else if (pNext(p)==NULL) p_Write0(p, ri);
360 else
361 {
362 r = pNext(p);
363 pNext(p) = NULL;
364 p_Write0(p, ri);
365 if (r!=NULL)
366 {
367 PrintS("+...");
368 pNext(p) = r;
369 }
370 }
371}

◆ writemon()

static void writemon ( poly  p,
int  ko,
const ring  r 
)
static

Definition at line 24 of file polys0.cc.

25{
26 assume(r != NULL);
27 const coeffs C = r->cf;
28 assume(C != NULL);
29
30 BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
31 const BOOLEAN bNotShortOut = (rShortOut(r) == FALSE);
32
33 if (((p_GetComp(p,r) == ko)
34 &&(p_LmIsConstantComp(p, r)))
35 || ((!n_IsOne(pGetCoeff(p),C))
36 && (!n_IsMOne(pGetCoeff(p),C))
37 )
38 )
39 {
40 if( bNotShortOut )
42 else
44
45 wroteCoef=(bNotShortOut)
46 || (rParameter(r)!=NULL)
47 || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
48 writeGen=TRUE;
49 }
50 else if (n_IsMOne(pGetCoeff(p),C))
51 {
53 {
54 if( bNotShortOut )
56 else
58
59 wroteCoef=(bNotShortOut)
60 || (rParameter(r)!=NULL)
61 || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
62 writeGen=TRUE;
63 }
64 else
65 StringAppendS("-");
66 }
67
68 int i;
69 {
70 for (i=0; i<rVar(r); i++)
71 {
72 {
73 long ee = p_GetExp(p,i+1,r);
74 if (ee!=0L)
75 {
76 if (wroteCoef)
77 StringAppendS("*");
78 //else
79 wroteCoef=(bNotShortOut);
80 writeGen=TRUE;
82 if (ee != 1L)
83 {
84 if (bNotShortOut) StringAppendS("^");
85 StringAppend("%ld", ee);
86 }
87 }
88 }
89 }
90 }
91 //StringAppend("{%d}",p->Order);
92 if (p_GetComp(p, r) != (long)ko)
93 {
94 if (writeGen) StringAppendS("*");
95 StringAppend("gen(%d)", p_GetComp(p, r));
96 }
97}
#define TRUE
Definition: auxiliary.h:100
int i
Definition: cfEzgcd.cc:132
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff 'n' represents the additive inverse of the one element, i.e. -1.
Definition: coeffs.h:469
static FORCE_INLINE void n_WriteLong(number n, const coeffs r)
write to the output buffer of the currently used reporter
Definition: coeffs.h:580
static FORCE_INLINE void n_WriteShort(number n, const coeffs r)
write to the output buffer of the currently used reporter in a shortest possible way,...
Definition: coeffs.h:585
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:465
#define StringAppend
Definition: emacs.cc:79
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
The main handler for Singular numbers which are suitable for Singular polynomials.
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:1004
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:467
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:518
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:545
static char * rRingVar(short i, const ring r)
Definition: ring.h:577
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:625
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:542
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592

◆ writemonLP()

static void writemonLP ( poly  p,
int  ko,
const ring  r 
)
static

Definition at line 104 of file polys0.cc.

105{
106 assume(r != NULL);
107 const coeffs C = r->cf;
108 assume(C != NULL);
109
110 BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
111
112 if (((p_GetComp(p,r) == ko)
113 &&(p_LmIsConstantComp(p, r)))
114 || ((!n_IsOne(pGetCoeff(p),C))
115 && (!n_IsMOne(pGetCoeff(p),C))
116 )
117 )
118 {
120
121 wroteCoef=TRUE;
122 writeGen=TRUE;
123 }
124 else if (n_IsMOne(pGetCoeff(p),C))
125 {
126 if (n_GreaterZero(pGetCoeff(p),C))
127 {
129
130 wroteCoef=TRUE;
131 writeGen=TRUE;
132 }
133 else
134 StringAppendS("-");
135 }
136
137 int i;
138 {
139 int lV = r->isLPring;
140 int lastVar = p_mLastVblock(p, r) * lV;
141 BOOLEAN wroteBlock = FALSE;
142 for (i=0; i<rVar(r); i++)
143 {
144 {
145 long ee = p_GetExp(p,i+1,r);
146 BOOLEAN endOfBlock = ((i+1) % lV) == 0;
147 BOOLEAN writeEmptyBlock = ee==0L && endOfBlock && !wroteBlock && i < lastVar;
148 if (ee!=0L || writeEmptyBlock)
149 {
150 if (wroteBlock)
151 StringAppendS("&");
152 else if (wroteCoef)
153 StringAppendS("*");
154 //else
155 wroteCoef=TRUE; //(bNotShortOut);
156 writeGen=TRUE;
157 if (writeEmptyBlock)
158 StringAppendS("_");
159 else
160 {
162 if (ee != 1L)
163 {
164 StringAppend("^%ld", ee);
165 }
166 wroteBlock = TRUE;
167 }
168 }
169 if (endOfBlock)
170 wroteBlock = FALSE;
171 }
172 }
173 }
174 //StringAppend("{%d}",p->Order);
175 if (p_GetComp(p, r) != (long)ko)
176 {
177 if (writeGen) StringAppendS("*");
178 StringAppend("gen(%d)", p_GetComp(p, r));
179 }
180}
int p_mLastVblock(poly p, const ring ri)
Definition: shiftop.cc:421