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)
 
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 229 of file polys0.cc.

230 {
231  StringSetS("");
232  p_String0(p, lmRing, tailRing);
233  return StringEndS();
234 }
char * StringEndS()
Definition: reporter.cc:151
void StringSetS(const char *st)
Definition: reporter.cc:128
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:179
int p
Definition: cfModGcd.cc:4019

◆ p_String0()

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

print p according to ShortOut in lmRing & tailRing

Definition at line 179 of file polys0.cc.

180 {
181  if (p == NULL)
182  {
183  StringAppendS("0");
184  return;
185  }
186  p_Normalize(p,lmRing);
187  if ((n_GetChar(lmRing->cf) == 0)
188  && (nCoeff_is_transExt(lmRing->cf)))
189  p_Normalize(p,lmRing); /* Manual/absfact.tst */
190  if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
191  {
192  writemon(p,0, lmRing);
193  p = pNext(p);
194  while (p!=NULL)
195  {
196  assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
197  if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
198  StringAppendS("+");
199  writemon(p,0, tailRing);
200  p = pNext(p);
201  }
202  return;
203  }
204 
205  long k = 1;
206  StringAppendS("[");
207  loop
208  {
209  while (k < p_GetComp(p,lmRing))
210  {
211  StringAppendS("0,");
212  k++;
213  }
214  writemon(p,k,lmRing);
215  pIter(p);
216  while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
217  {
218  if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
219  writemon(p,k,tailRing);
220  pIter(p);
221  }
222  if (p == NULL) break;
223  StringAppendS(",");
224  k++;
225  }
226  StringAppendS("]");
227 }
#define p_GetComp(p, r)
Definition: monomials.h:64
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
int k
Definition: cfEzgcd.cc:92
#define loop
Definition: structs.h:80
#define pIter(p)
Definition: monomials.h:37
#define assume(x)
Definition: mod2.h:390
void StringAppendS(const char *st)
Definition: reporter.cc:107
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:940
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:464
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define NULL
Definition: omList.c:12
#define pNext(p)
Definition: monomials.h:36
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:494
int p
Definition: cfModGcd.cc:4019
static void writemon(poly p, int ko, const ring r)
Definition: polys0.cc:24

◆ 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 159 of file polys0.cc.

160 {
161  // NOTE: the following (non-thread-safe!) UGLYNESS
162  // (changing naRing->ShortOut for a while) is due to Hans!
163  // Just think of other ring using the VERY SAME naRing and possible
164  // side-effects...
165  // but this is not a problem: i/o is not thread-safe anyway.
166  const BOOLEAN bLMShortOut = rShortOut(lmRing);
167  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
168 
169  lmRing->ShortOut = FALSE;
170  tailRing->ShortOut = FALSE;
171 
172  p_String0(p, lmRing, tailRing);
173 
174  lmRing->ShortOut = bLMShortOut;
175  tailRing->ShortOut = bTAILShortOut;
176 }
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:575
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:179
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85

◆ 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 140 of file polys0.cc.

141 {
142  // NOTE: the following (non-thread-safe!) UGLYNESS
143  // (changing naRing->ShortOut for a while) is due to Hans!
144  // Just think of other ring using the VERY SAME naRing and possible
145  // side-effects...
146  const BOOLEAN bLMShortOut = rShortOut(lmRing);
147  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
148 
149  lmRing->ShortOut = rCanShortOut(lmRing);
150  tailRing->ShortOut = rCanShortOut(tailRing);
151 
152  p_String0(p, lmRing, tailRing);
153 
154  lmRing->ShortOut = bLMShortOut;
155  tailRing->ShortOut = bTAILShortOut;
156 }
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:575
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:580
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:179
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85

◆ p_Write()

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

Definition at line 249 of file polys0.cc.

250 {
251  p_Write0(p, lmRing, tailRing);
252  PrintLn();
253 }
void PrintLn()
Definition: reporter.cc:310
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:239
int p
Definition: cfModGcd.cc:4019

◆ p_Write0()

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

Definition at line 239 of file polys0.cc.

240 {
241  char *s=p_String(p, lmRing, tailRing);
242  PrintS(s);
243  omFree(s);
244 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:229
#define omFree(addr)
Definition: omAllocDecl.h:261
void PrintS(const char *s)
Definition: reporter.cc:284
int p
Definition: cfModGcd.cc:4019

◆ p_wrp()

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

Definition at line 280 of file polys0.cc.

281 {
282  poly r;
283 
284  if (p==NULL) PrintS("NULL");
285  else if (pNext(p)==NULL) p_Write0(p, lmRing);
286  else
287  {
288  r = pNext(pNext(p));
289  pNext(pNext(p)) = NULL;
290  p_Write0(p, tailRing);
291  if (r!=NULL)
292  {
293  PrintS("+...");
294  pNext(pNext(p)) = r;
295  }
296  }
297 }
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:239
void PrintS(const char *s)
Definition: reporter.cc:284
#define NULL
Definition: omList.c:12
#define pNext(p)
Definition: monomials.h:36
int p
Definition: cfModGcd.cc:4019

◆ p_wrp0()

void p_wrp0 ( poly  p,
ring  ri 
)

Definition at line 261 of file polys0.cc.

262 {
263  poly r;
264 
265  if (p==NULL) PrintS("NULL");
266  else if (pNext(p)==NULL) p_Write0(p, ri);
267  else
268  {
269  r = pNext(p);
270  pNext(p) = NULL;
271  p_Write0(p, ri);
272  if (r!=NULL)
273  {
274  PrintS("+...");
275  pNext(p) = r;
276  }
277  }
278 }
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:239
void PrintS(const char *s)
Definition: reporter.cc:284
#define NULL
Definition: omList.c:12
#define pNext(p)
Definition: monomials.h:36
int p
Definition: cfModGcd.cc:4019

◆ 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  {
52  if (n_GreaterZero(pGetCoeff(p),C))
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 #ifdef HAVE_SHIFTBBA
70  if (rIsLPRing(r)) // this implies bNotShortOut
71  {
72  int lV = r->isLPring;
73  int lastVar = p_mLastVblock(p, r) * lV;
74  BOOLEAN wroteBlock = FALSE;
75  for (i=0; i<rVar(r); i++)
76  {
77  {
78  long ee = p_GetExp(p,i+1,r);
79  BOOLEAN endOfBlock = ((i+1) % lV) == 0;
80  BOOLEAN writeEmptyBlock = ee==0L && endOfBlock && !wroteBlock && i < lastVar;
81  if (ee!=0L || writeEmptyBlock)
82  {
83  if (wroteBlock)
84  StringAppendS("&");
85  else if (wroteCoef)
86  StringAppendS("*");
87  //else
88  wroteCoef=TRUE; //(bNotShortOut);
89  writeGen=TRUE;
90  if (writeEmptyBlock)
91  StringAppendS("_");
92  else
93  {
94  StringAppendS(rRingVar(i, r));
95  if (ee != 1L)
96  {
97  StringAppend("^%ld", ee);
98  }
99  wroteBlock = TRUE;
100  }
101  }
102  if (endOfBlock)
103  wroteBlock = FALSE;
104  }
105  }
106  }
107  else
108 #endif
109  {
110  for (i=0; i<rVar(r); i++)
111  {
112  {
113  long ee = p_GetExp(p,i+1,r);
114  if (ee!=0L)
115  {
116  if (wroteCoef)
117  StringAppendS("*");
118  //else
119  wroteCoef=(bNotShortOut);
120  writeGen=TRUE;
121  StringAppendS(rRingVar(i, r));
122  if (ee != 1L)
123  {
124  if (bNotShortOut) StringAppendS("^");
125  StringAppend("%ld", ee);
126  }
127  }
128  }
129  }
130  }
131  //StringAppend("{%d}",p->Order);
132  if (p_GetComp(p, r) != (long)ko)
133  {
134  if (writeGen) StringAppendS("*");
135  StringAppend("gen(%d)", p_GetComp(p, r));
136  }
137 }
int p_mLastVblock(poly p, const ring ri)
Definition: shiftop.cc:412
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:961
#define FALSE
Definition: auxiliary.h:94
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:468
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:513
#define p_GetComp(p, r)
Definition: monomials.h:64
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:575
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:586
#define TRUE
Definition: auxiliary.h:98
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:619
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
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:408
static FORCE_INLINE void n_WriteLong(number n, const coeffs r)
write to the output buffer of the currently used reporter
Definition: coeffs.h:583
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
#define assume(x)
Definition: mod2.h:390
The main handler for Singular numbers which are suitable for Singular polynomials.
void StringAppendS(const char *st)
Definition: reporter.cc:107
#define StringAppend
Definition: emacs.cc:79
int i
Definition: cfEzgcd.cc:125
static char * rRingVar(short i, const ring r)
Definition: ring.h:571
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:540
#define NULL
Definition: omList.c:12
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:537
static FORCE_INLINE BOOLEAN n_IsMOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the additive inverse of the one element, i.e. -1.
Definition: coeffs.h:472
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:494
int p
Definition: cfModGcd.cc:4019
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, e.g. in K(a): a2 instead of a^2
Definition: coeffs.h:588
int BOOLEAN
Definition: auxiliary.h:85