My Project  UNKNOWN_GIT_VERSION
Functions
polys0.cc File Reference
#include "misc/auxiliary.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.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 184 of file polys0.cc.

185 {
186  StringSetS("");
187  p_String0(p, lmRing, tailRing);
188  return StringEndS();
189 }

◆ p_String0()

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

print p according to ShortOut in lmRing & tailRing

Definition at line 134 of file polys0.cc.

135 {
136  if (p == NULL)
137  {
138  StringAppendS("0");
139  return;
140  }
141  p_Normalize(p,lmRing);
142  if ((n_GetChar(lmRing->cf) == 0)
143  && (nCoeff_is_transExt(lmRing->cf)))
144  p_Normalize(p,lmRing); /* Manual/absfact.tst */
145  if ((p_GetComp(p, lmRing) == 0) || (!lmRing->VectorOut))
146  {
147  writemon(p,0, lmRing);
148  p = pNext(p);
149  while (p!=NULL)
150  {
151  assume((p->coef==NULL)||(!n_IsZero(p->coef,tailRing->cf)));
152  if ((p->coef==NULL)||n_GreaterZero(p->coef,tailRing->cf))
153  StringAppendS("+");
154  writemon(p,0, tailRing);
155  p = pNext(p);
156  }
157  return;
158  }
159 
160  long k = 1;
161  StringAppendS("[");
162  loop
163  {
164  while (k < p_GetComp(p,lmRing))
165  {
166  StringAppendS("0,");
167  k++;
168  }
169  writemon(p,k,lmRing);
170  pIter(p);
171  while ((p!=NULL) && (k == p_GetComp(p, tailRing)))
172  {
173  if (n_GreaterZero(p->coef,tailRing->cf)) StringAppendS("+");
174  writemon(p,k,tailRing);
175  pIter(p);
176  }
177  if (p == NULL) break;
178  StringAppendS(",");
179  k++;
180  }
181  StringAppendS("]");
182 }

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

115 {
116  // NOTE: the following (non-thread-safe!) UGLYNESS
117  // (changing naRing->ShortOut for a while) is due to Hans!
118  // Just think of other ring using the VERY SAME naRing and possible
119  // side-effects...
120  // but this is not a problem: i/o is not thread-safe anyway.
121  const BOOLEAN bLMShortOut = rShortOut(lmRing);
122  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
123 
124  lmRing->ShortOut = FALSE;
125  tailRing->ShortOut = FALSE;
126 
127  p_String0(p, lmRing, tailRing);
128 
129  lmRing->ShortOut = bLMShortOut;
130  tailRing->ShortOut = bTAILShortOut;
131 }

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

96 {
97  // NOTE: the following (non-thread-safe!) UGLYNESS
98  // (changing naRing->ShortOut for a while) is due to Hans!
99  // Just think of other ring using the VERY SAME naRing and possible
100  // side-effects...
101  const BOOLEAN bLMShortOut = rShortOut(lmRing);
102  const BOOLEAN bTAILShortOut = rShortOut(tailRing);
103 
104  lmRing->ShortOut = rCanShortOut(lmRing);
105  tailRing->ShortOut = rCanShortOut(tailRing);
106 
107  p_String0(p, lmRing, tailRing);
108 
109  lmRing->ShortOut = bLMShortOut;
110  tailRing->ShortOut = bTAILShortOut;
111 }

◆ p_Write()

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

Definition at line 204 of file polys0.cc.

205 {
206  p_Write0(p, lmRing, tailRing);
207  PrintLn();
208 }

◆ p_Write0()

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

Definition at line 194 of file polys0.cc.

195 {
196  char *s=p_String(p, lmRing, tailRing);
197  PrintS(s);
198  omFree(s);
199 }

◆ p_wrp()

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

Definition at line 235 of file polys0.cc.

236 {
237  poly r;
238 
239  if (p==NULL) PrintS("NULL");
240  else if (pNext(p)==NULL) p_Write0(p, lmRing);
241  else
242  {
243  r = pNext(pNext(p));
244  pNext(pNext(p)) = NULL;
245  p_Write0(p, tailRing);
246  if (r!=NULL)
247  {
248  PrintS("+...");
249  pNext(pNext(p)) = r;
250  }
251  }
252 }

◆ p_wrp0()

void p_wrp0 ( poly  p,
ring  ri 
)

Definition at line 216 of file polys0.cc.

217 {
218  poly r;
219 
220  if (p==NULL) PrintS("NULL");
221  else if (pNext(p)==NULL) p_Write0(p, ri);
222  else
223  {
224  r = pNext(p);
225  pNext(p) = NULL;
226  p_Write0(p, ri);
227  if (r!=NULL)
228  {
229  PrintS("+...");
230  pNext(p) = r;
231  }
232  }
233 }

◆ writemon()

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

Definition at line 21 of file polys0.cc.

22 {
23  assume(r != NULL);
24  const coeffs C = r->cf;
25  assume(C != NULL);
26 
27  BOOLEAN wroteCoef=FALSE,writeGen=FALSE;
28  const BOOLEAN bNotShortOut = (rShortOut(r) == FALSE);
29 
30  if (((p_GetComp(p,r) == ko)
31  &&(p_LmIsConstantComp(p, r)))
32  || ((!n_IsOne(pGetCoeff(p),C))
33  && (!n_IsMOne(pGetCoeff(p),C))
34  )
35  )
36  {
37  if( bNotShortOut )
39  else
41 
42  wroteCoef=(bNotShortOut)
43  || (rParameter(r)!=NULL)
44  || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
45  writeGen=TRUE;
46  }
47  else if (n_IsMOne(pGetCoeff(p),C))
48  {
49  if (n_GreaterZero(pGetCoeff(p),C))
50  {
51  if( bNotShortOut )
53  else
55 
56  wroteCoef=(bNotShortOut)
57  || (rParameter(r)!=NULL)
58  || rField_is_R(r) || (rField_is_long_R(r)) || (rField_is_long_C(r));
59  writeGen=TRUE;
60  }
61  else
62  StringAppendS("-");
63  }
64 
65  int i;
66  for (i=0; i<rVar(r); i++)
67  {
68  {
69  long ee = p_GetExp(p,i+1,r);
70  if (ee!=0L)
71  {
72  if (wroteCoef)
73  StringAppendS("*");
74  //else
75  wroteCoef=(bNotShortOut);
76  writeGen=TRUE;
78  if (ee != 1L)
79  {
80  if (bNotShortOut) StringAppendS("^");
81  StringAppend("%ld", ee);
82  }
83  }
84  }
85  }
86  //StringAppend("{%d}",p->Order);
87  if (p_GetComp(p, r) != (long)ko)
88  {
89  if (writeGen) StringAppendS("*");
90  StringAppend("gen(%d)", p_GetComp(p, r));
91  }
92 }
n_WriteLong
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
FALSE
#define FALSE
Definition: auxiliary.h:94
rField_is_long_R
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:533
writemon
static void writemon(poly p, int ko, const ring r)
Definition: polys0.cc:21
p_GetComp
#define p_GetComp(p, r)
Definition: monomials.h:65
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:107
p_LmIsConstantComp
static BOOLEAN p_LmIsConstantComp(const poly p, const ring r)
Definition: p_polys.h:963
p_GetExp
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:470
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
p_Normalize
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3723
k
int k
Definition: cfEzgcd.cc:92
rCanShortOut
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:576
n_GetChar
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:444
p_String
char * p_String(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:184
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
StringEndS
char * StringEndS()
Definition: reporter.cc:151
n_IsOne
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
loop
#define loop
Definition: structs.h:78
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
PrintS
void PrintS(const char *s)
Definition: reporter.cc:284
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
rRingVar
static char * rRingVar(short i, const ring r)
Definition: ring.h:567
p_Write0
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:194
coeffs
pIter
#define pIter(p)
Definition: monomials.h:38
rField_is_R
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:509
nCoeff_is_transExt
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:940
n_WriteShort
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:588
StringSetS
void StringSetS(const char *st)
Definition: reporter.cc:128
n_IsMOne
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:472
n_GreaterZero
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:494
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
StringAppend
#define StringAppend
Definition: emacs.cc:79
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
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
p_String0
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:134
PrintLn
void PrintLn()
Definition: reporter.cc:310
rParameter
static const char ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:615
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:536
rShortOut
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:571
pNext
#define pNext(p)
Definition: monomials.h:37