Macros | Functions
clapconv.cc File Reference
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <factory/factory.h>
#include <coeffs/coeffs.h>
#include <coeffs/longrat.h>
#include <polys/monomials/p_polys.h>
#include <polys/sbuckets.h>
#include <polys/clapconv.h>
#include "simpleideals.h"
#include <polys/ext_fields/transext.h>

Go to the source code of this file.

Macros

#define TRANSEXT_PRIVATES
 

Functions

void out_cf (const char *s1, const CanonicalForm &f, const char *s2)
 
static void conv_RecPP (const CanonicalForm &f, int *exp, sBucket_pt result, ring r)
 
static void convRecTrP (const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
 
static number convFactoryNSingAN (const CanonicalForm &f, const ring r)
 
poly convFactoryPSingP (const CanonicalForm &f, const ring r)
 
CanonicalForm convSingPFactoryP (poly p, const ring r)
 
int convFactoryISingI (const CanonicalForm &f)
 
CanonicalForm convSingAPFactoryAP (poly p, const Variable &a, const ring r)
 
static void convRecAP_R (const CanonicalForm &f, int *exp, poly &result, int par_start, int var_start, const ring r)
 
poly convFactoryAPSingAP_R (const CanonicalForm &f, int par_start, int var_start, const ring r)
 
poly convFactoryAPSingAP (const CanonicalForm &f, const ring r)
 
CanonicalForm convSingAFactoryA (poly p, const Variable &a, const ring r)
 
poly convFactoryASingA (const CanonicalForm &f, const ring r)
 
CanonicalForm convSingTrPFactoryP (poly p, const ring r)
 
poly convFactoryPSingTrP (const CanonicalForm &f, const ring r)
 

Macro Definition Documentation

◆ TRANSEXT_PRIVATES

#define TRANSEXT_PRIVATES

Definition at line 28 of file clapconv.cc.

Function Documentation

◆ conv_RecPP()

static void conv_RecPP ( const CanonicalForm f,
int *  exp,
sBucket_pt  result,
ring  r 
)
static

Definition at line 54 of file clapconv.cc.

55 {
56  if (f.isZero())
57  return;
58  if ( ! f.inCoeffDomain() )
59  {
60  int l = f.level();
61  for ( CFIterator i = f; i.hasTerms(); i++ )
62  {
63  exp[l] = i.exp();
64  conv_RecPP( i.coeff(), exp, result, r );
65  }
66  exp[l] = 0;
67  }
68  else
69  {
70  poly term = p_Init(r);
71  pNext( term ) = NULL;
72  for ( int i = 1; i <= r->N; i++ )
73  p_SetExp( term, i, exp[i], r);
74  pGetCoeff( term )=r->cf->convFactoryNSingN(f, r->cf);
75  p_Setm( term, r );
76  if ( n_IsZero(pGetCoeff(term), r->cf) )
77  {
78  p_Delete(&term,r);
79  }
80  else
81  {
82  sBucket_Merge_p(result,term,1);
83  }
84  }
85 }
Definition: int_poly.h:33
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
const ring r
Definition: syzextra.cc:208
void sBucket_Merge_p(sBucket_pt bucket, poly p, int length)
Merges p into Spoly: assumes Bpoly and p have no common monoms destroys p!
Definition: sbuckets.cc:176
static void conv_RecPP(const CanonicalForm &f, int *exp, sBucket_pt result, ring r)
Definition: clapconv.cc:54
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
int level() const
level() returns the level of CO.
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
bool inCoeffDomain() const

◆ convFactoryAPSingAP()

poly convFactoryAPSingAP ( const CanonicalForm f,
const ring  r 
)

Definition at line 155 of file clapconv.cc.

156 {
157  return convFactoryAPSingAP_R(f,0,rPar(r),r);
158 }
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
const ring r
Definition: syzextra.cc:208
poly convFactoryAPSingAP_R(const CanonicalForm &f, int par_start, int var_start, const ring r)
Definition: clapconv.cc:145

◆ convFactoryAPSingAP_R()

poly convFactoryAPSingAP_R ( const CanonicalForm f,
int  par_start,
int  var_start,
const ring  r 
)

Definition at line 145 of file clapconv.cc.

146 {
147  int n = rVar(r)+rPar(r)+1;
148  int * exp = (int *)omAlloc0(n*sizeof(int));
149  poly result = NULL;
150  convRecAP_R( f, exp, result,par_start, var_start, r );
151  omFreeSize((ADDRESS)exp,n*sizeof(int));
152  return result;
153 }
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
const ring r
Definition: syzextra.cc:208
#define NULL
Definition: omList.c:10
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
static void convRecAP_R(const CanonicalForm &f, int *exp, poly &result, int par_start, int var_start, const ring r)
Definition: clapconv.cc:160
#define omAlloc0(size)
Definition: omAllocDecl.h:211
return result
Definition: facAbsBiFact.cc:76

◆ convFactoryASingA()

poly convFactoryASingA ( const CanonicalForm f,
const ring  r 
)

Definition at line 257 of file clapconv.cc.

258 {
259  poly a=NULL;
260  poly t;
261  for( CFIterator i=f; i.hasTerms(); i++)
262  {
263  t= p_Init (r->cf->extRing);
264  p_GetCoeff(t, r->cf->extRing)= convFactoryNSingAN( i.coeff(), r );
265  if (n_IsZero(p_GetCoeff(t,r->cf->extRing),r->cf->extRing->cf))
266  {
267  p_Delete(&t,r->cf->extRing);
268  }
269  else
270  {
271  p_SetExp(t,1,i.exp(),r->cf->extRing);
272  a=p_Add_q(a,t,r->cf->extRing);
273  }
274  }
275  if (a!=NULL)
276  {
277  if( r->cf->extRing != NULL )
278  if (r->cf->extRing->qideal->m[0]!=NULL)
279  {
280  poly l=r->cf->extRing->qideal->m[0];
281  if (p_GetExp(a,1,r->cf->extRing) >= p_GetExp(l,1,r->cf->extRing))
282  a = p_PolyDiv (a, l, FALSE, r->cf->extRing); // ???
283  }
284  }
285  return a;
286 }
const poly a
Definition: syzextra.cc:212
#define FALSE
Definition: auxiliary.h:94
const ring r
Definition: syzextra.cc:208
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:464
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:468
poly p_PolyDiv(poly &p, const poly divisor, const BOOLEAN needResult, const ring r)
assumes that p and divisor are univariate polynomials in r, mentioning the same variable; assumes div...
Definition: p_polys.cc:1823
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
static number convFactoryNSingAN(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:248
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define p_GetCoeff(p, r)
Definition: monomials.h:57
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
int l
Definition: cfEzgcd.cc:94

◆ convFactoryISingI()

int convFactoryISingI ( const CanonicalForm f)

Definition at line 114 of file clapconv.cc.

115 {
116  if (!f.isImm()) WerrorS("int overflow in det");
117  return f.intval();
118 }
long intval() const
conversion functions
bool isImm() const
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ convFactoryNSingAN()

static number convFactoryNSingAN ( const CanonicalForm f,
const ring  r 
)
static

Definition at line 248 of file clapconv.cc.

249 {
250  assume (r != NULL);
251  assume (r->cf != NULL);
252  assume (r->cf->extRing != NULL);
253  // r->cf->extRing->cf has to be Q or Z/p (the supported types of factory)
254  return n_convFactoryNSingN( f, r->cf->extRing->cf );
255 }
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:587
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
#define NULL
Definition: omList.c:10

◆ convFactoryPSingP()

poly convFactoryPSingP ( const CanonicalForm f,
const ring  r 
)

Definition at line 41 of file clapconv.cc.

42 {
43  int n = rVar(r)+1;
44  /* ASSERT( level( f ) <= pVariables, "illegal number of variables" ); */
45  int * exp = (int*)omAlloc0(n*sizeof(int));
46  sBucket_pt result_bucket=sBucketCreate(r);
47  conv_RecPP( f, exp, result_bucket, r );
48  poly result; int dummy;
49  sBucketDestroyMerge(result_bucket,&result,&dummy);
50  omFreeSize((ADDRESS)exp,n*sizeof(int));
51  return result;
52 }
void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:65
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
const ring r
Definition: syzextra.cc:208
static void conv_RecPP(const CanonicalForm &f, int *exp, sBucket_pt result, ring r)
Definition: clapconv.cc:54
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:120
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
return result
Definition: facAbsBiFact.cc:76

◆ convFactoryPSingTrP()

poly convFactoryPSingTrP ( const CanonicalForm f,
const ring  r 
)

Definition at line 324 of file clapconv.cc.

325 {
326  int n = rVar(r)+1;
327  int * exp = (int*)omAlloc0(n*sizeof(int));
328  poly result = NULL;
329  convRecTrP( f, exp, result , rPar(r), r );
330  omFreeSize((ADDRESS)exp,n*sizeof(int));
331  return result;
332 }
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
const ring r
Definition: syzextra.cc:208
static void convRecTrP(const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
Definition: clapconv.cc:335
#define NULL
Definition: omList.c:10
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
return result
Definition: facAbsBiFact.cc:76

◆ convRecAP_R()

static void convRecAP_R ( const CanonicalForm f,
int *  exp,
poly result,
int  par_start,
int  var_start,
const ring  r 
)
static

Definition at line 160 of file clapconv.cc.

161 {
162  if (f.isZero())
163  return;
164  if ( ! f.inCoeffDomain() )
165  {
166  int l = f.level();
167  for ( CFIterator i = f; i.hasTerms(); i++ )
168  {
169  exp[l] = i.exp();
170  convRecAP_R( i.coeff(), exp, result, par_start, var_start, r);
171  }
172  exp[l] = 0;
173  }
174  else
175  {
176  poly z=(poly)convFactoryASingA( f,r );
177  if (z!=NULL)
178  {
179  poly term = p_Init(r);
180  pNext( term ) = NULL;
181  int i;
182  for ( i = rVar(r); i>0 ; i-- )
183  p_SetExp( term, i , exp[i+var_start],r);
184  //if (rRing_has_Comp(currRing->extRing)) p_SetComp(term, 0, currRing->extRing); // done by pInit
185  if (par_start==0)
186  {
187  for ( i = 1; i <= var_start; i++ )
188  //z->e[i-1]+=exp[i];
189  p_AddExp(z,i,exp[i],r->cf->extRing);
190  }
191  else
192  {
193  for ( i = par_start+1; i <= var_start+rPar(r); i++ )
194  //z->e[i-1]+=exp[i];
195  p_AddExp(z,i,exp[i-par_start],r->cf->extRing);
196  }
197  pGetCoeff(term)=(number)ALLOC0_RNUMBER();
198  p_GetCoeff(term, r->cf->extRing)=(number) z;
199  p_Setm( term,r );
200  result = p_Add_q( result, term, r );
201  }
202  }
203 }
Definition: int_poly.h:33
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
poly convFactoryASingA(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:257
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
static long p_AddExp(poly p, int v, long ee, ring r)
Definition: p_polys.h:601
#define p_GetCoeff(p, r)
Definition: monomials.h:57
int level() const
level() returns the level of CO.
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
static void convRecAP_R(const CanonicalForm &f, int *exp, poly &result, int par_start, int var_start, const ring r)
Definition: clapconv.cc:160
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
#define ALLOC0_RNUMBER()
Definition: coeffs.h:88
bool inCoeffDomain() const

◆ convRecTrP()

static void convRecTrP ( const CanonicalForm f,
int *  exp,
poly result,
int  offs,
const ring  r 
)
static

Definition at line 335 of file clapconv.cc.

336 {
337  if (f.isZero())
338  return;
339  if ( f.level() > offs )
340  {
341  int l = f.level();
342  for ( CFIterator i = f; i.hasTerms(); i++ )
343  {
344  exp[l-offs] = i.exp();
345  convRecTrP( i.coeff(), exp, result, offs, r );
346  }
347  exp[l-offs] = 0;
348  }
349  else
350  {
351  poly term = p_Init(r);
352  pNext( term ) = NULL;
353  for ( int i = rVar(r); i>0; i-- )
354  p_SetExp( term, i ,exp[i], r);
355  //if (rRing_has_Comp(currRing)) p_SetComp(term, 0, currRing); // done by pInit
356  pGetCoeff(term)=ntInit(convFactoryPSingP( f, r->cf->extRing ), r->cf);
357  p_Setm( term,r );
358  result = p_Add_q( result, term,r );
359  }
360 }
Definition: int_poly.h:33
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
const ring r
Definition: syzextra.cc:208
number ntInit(long i, const coeffs cf)
Definition: transext.cc:692
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
static void convRecTrP(const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
Definition: clapconv.cc:335
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
int level() const
level() returns the level of CO.
p exp[i]
Definition: DebugPrint.cc:39
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1243
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94

◆ convSingAFactoryA()

CanonicalForm convSingAFactoryA ( poly  p,
const Variable a,
const ring  r 
)

Definition at line 205 of file clapconv.cc.

206 {
207  CanonicalForm result = 0;
208  int e;
209 
210  while ( p!=NULL )
211  {
213  if ( rField_is_Zp_a(r) )
214  {
215  term = n_Int( p_GetCoeff( p, r->cf->extRing ), r->cf->extRing->cf );
216  }
217  else
218  {
219  if ( SR_HDL(p_GetCoeff( p, r->cf->extRing )) & SR_INT )
220  term = SR_TO_INT(p_GetCoeff( p, r->cf->extRing )) ;
221  else
222  {
223  if ( p_GetCoeff( p, r->cf->extRing )->s == 3 )
224  {
225  mpz_t dummy;
226  mpz_init_set( dummy, (p_GetCoeff( p,r->cf->extRing )->z) );
227  term = make_cf( dummy );
228  }
229  else
230  {
231  // assume s==0 or s==1
232  mpz_t num, den;
233  On(SW_RATIONAL);
234  mpz_init_set( num, (p_GetCoeff( p, r->cf->extRing )->z) );
235  mpz_init_set( den, (p_GetCoeff( p, r->cf->extRing )->n) );
236  term = make_cf( num, den, ( p_GetCoeff( p, r->cf->extRing )->s != 1 ));
237  }
238  }
239  }
240  if ( (e = p_GetExp( p, 1, r->cf->extRing )) != 0 )
241  term *= power( a , e );
242  result += term;
243  p = pNext( p );
244  }
245  return result;
246 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:521
CanonicalForm num(const CanonicalForm &f)
Definition: int_poly.h:33
return P p
Definition: myNF.cc:203
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm make_cf(const mpz_ptr n)
Definition: singext.cc:70
const ring r
Definition: syzextra.cc:208
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ...
Definition: coeffs.h:551
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:464
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
#define SR_TO_INT(SR)
Definition: longrat.h:70
#define NULL
Definition: omList.c:10
CanonicalForm den(const CanonicalForm &f)
#define SR_INT
Definition: longrat.h:68
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
#define SR_HDL(A)
Definition: tgb.cc:35
return result
Definition: facAbsBiFact.cc:76

◆ convSingAPFactoryAP()

CanonicalForm convSingAPFactoryAP ( poly  p,
const Variable a,
const ring  r 
)

Definition at line 120 of file clapconv.cc.

121 {
122  CanonicalForm result = 0;
123  int e, n = r-> N;
124  int off=rPar(r);
125 
126  if (!rField_is_Zp_a(r))
127  On(SW_RATIONAL);
128  while ( p!=NULL)
129  {
130  CanonicalForm term=convSingAFactoryA(((poly)p_GetCoeff(p, r->cf->extRing)),a, r);
131  for ( int i = 1; i <= n; i++ )
132  {
133  if ( (e = p_GetExp( p, i, r )) != 0 )
134  term *= power( Variable( i + off), e );
135  }
136  result += term;
137  pIter( p );
138  }
139  return result;
140 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:521
Definition: int_poly.h:33
return P p
Definition: myNF.cc:203
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
factory&#39;s class for variables
Definition: factory.h:115
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm convSingAFactoryA(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:205
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
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:464
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define p_GetCoeff(p, r)
Definition: monomials.h:57
polyrec * poly
Definition: hilb.h:10
return result
Definition: facAbsBiFact.cc:76

◆ convSingPFactoryP()

CanonicalForm convSingPFactoryP ( poly  p,
const ring  r 
)

Definition at line 88 of file clapconv.cc.

89 {
91  int e, n = rVar(r);
92  BOOLEAN setChar=TRUE;
93 
94  p=pReverse(p);
95  poly op=p;
96  while ( p!=NULL )
97  {
99  term=r->cf->convSingNFactoryN(pGetCoeff( p ),setChar, r->cf);
100  if (errorreported) break;
101  setChar=FALSE;
102  for ( int i = n; i >0; i-- )
103  {
104  if ( (e = p_GetExp( p, i, r)) != 0 )
105  term *= power( Variable( i ), e );
106  }
107  result += term;
108  pIter( p );
109  }
110  op=pReverse(op);
111  return result;
112 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: int_poly.h:33
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
factory&#39;s class for variables
Definition: factory.h:115
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
factory&#39;s main class
Definition: canonicalform.h:75
#define TRUE
Definition: auxiliary.h:98
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
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:464
int i
Definition: cfEzgcd.cc:123
static poly pReverse(poly p)
Definition: p_polys.h:330
short errorreported
Definition: feFopen.cc:23
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:85
return result
Definition: facAbsBiFact.cc:76

◆ convSingTrPFactoryP()

CanonicalForm convSingTrPFactoryP ( poly  p,
const ring  r 
)

Definition at line 288 of file clapconv.cc.

289 {
290  CanonicalForm result = 0;
291  int e, n = rVar(r);
292  int offs = rPar(r);
293 
294  while ( p!=NULL )
295  {
296  n_Normalize(p_GetCoeff(p, r), r->cf);
297 
298  // test if denominator is constant
299  if (!p_IsConstantPoly(DEN ((fraction)p_GetCoeff (p,r)),r->cf->extRing) && !errorreported)
300  WerrorS("conversion error: denominator!= 1");
301 
302  CanonicalForm term=convSingPFactoryP(NUM ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
303 
304  // if denominator is not NULL it should be a constant at this point
305  if (DEN ((fraction)p_GetCoeff(p,r)) != NULL)
306  {
307  CanonicalForm den= convSingPFactoryP(DEN ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
308  if (rChar (r) == 0)
309  On (SW_RATIONAL);
310  term /= den;
311  }
312 
313  for ( int i = n; i > 0; i-- )
314  {
315  if ( (e = p_GetExp( p, i,r )) != 0 )
316  term = term * power( Variable( i + offs ), e );
317  }
318  result += term;
319  p = pNext( p );
320  }
321  return result;
322 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: int_poly.h:33
return P p
Definition: myNF.cc:203
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
factory&#39;s class for variables
Definition: factory.h:115
int rChar(ring r)
Definition: ring.cc:686
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
factory&#39;s main class
Definition: canonicalform.h:75
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:582
void WerrorS(const char *s)
Definition: feFopen.cc:24
const ring r
Definition: syzextra.cc:208
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:464
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
int i
Definition: cfEzgcd.cc:123
short errorreported
Definition: feFopen.cc:23
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
CanonicalForm den(const CanonicalForm &f)
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1890
#define pNext(p)
Definition: monomials.h:43
#define p_GetCoeff(p, r)
Definition: monomials.h:57
return result
Definition: facAbsBiFact.cc:76

◆ out_cf()

void out_cf ( const char *  s1,
const CanonicalForm f,
const char *  s2 
)

Definition at line 90 of file cf_factor.cc.

91 {
92  printf("%s",s1);
93  if (f.isZero()) printf("+0");
94  //else if (! f.inCoeffDomain() )
95  else if (! f.inBaseDomain() )
96  {
97  int l = f.level();
98  for ( CFIterator i = f; i.hasTerms(); i++ )
99  {
100  int e=i.exp();
101  if (i.coeff().isOne())
102  {
103  printf("+");
104  if (e==0) printf("1");
105  else
106  {
107  printf("v(%d)",l);
108  if (e!=1) printf("^%d",e);
109  }
110  }
111  else
112  {
113  out_cf("+(",i.coeff(),")");
114  if (e!=0)
115  {
116  printf("*v(%d)",l);
117  if (e!=1) printf("^%d",e);
118  }
119  }
120  }
121  }
122  else
123  {
124  if ( f.isImm() )
125  {
127  {
128  long a= imm2int (f.getval());
129  if ( a == gf_q )
130  printf ("+%ld", a);
131  else if ( a == 0L )
132  printf ("+1");
133  else if ( a == 1L )
134  printf ("+%c",gf_name);
135  else
136  {
137  printf ("+%c",gf_name);
138  printf ("^%ld",a);
139  }
140  }
141  else
142  printf("+%ld",f.intval());
143  }
144  else
145  {
146  #ifdef NOSTREAMIO
147  if (f.inZ())
148  {
149  mpz_t m;
150  gmp_numerator(f,m);
151  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
152  str = mpz_get_str( str, 10, m );
153  printf("%s",str);
154  delete[] str;
155  mpz_clear(m);
156  }
157  else if (f.inQ())
158  {
159  mpz_t m;
160  gmp_numerator(f,m);
161  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
162  str = mpz_get_str( str, 10, m );
163  printf("%s/",str);
164  delete[] str;
165  mpz_clear(m);
166  gmp_denominator(f,m);
167  str = new char[mpz_sizeinbase( m, 10 ) + 2];
168  str = mpz_get_str( str, 10, m );
169  printf("%s",str);
170  delete[] str;
171  mpz_clear(m);
172  }
173  #else
174  std::cout << f;
175  #endif
176  }
177  //if (f.inZ()) printf("(Z)");
178  //else if (f.inQ()) printf("(Q)");
179  //else if (f.inFF()) printf("(FF)");
180  //else if (f.inPP()) printf("(PP)");
181  //else if (f.inGF()) printf("(PP)");
182  //else
183  if (f.inExtension()) printf("E(%d)",f.level());
184  }
185  printf("%s",s2);
186 }
long intval() const
conversion functions
const poly a
Definition: syzextra.cc:212
bool isImm() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
char gf_name
Definition: gfops.cc:52
int gf_q
Definition: gfops.cc:47
bool inBaseDomain() const
int m
Definition: cfEzgcd.cc:119
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
Definition: cf_factor.cc:90
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
static int gettype()
Definition: cf_factory.h:28
bool inQ() const
bool inZ() const
predicates
#define GaloisFieldDomain
Definition: cf_defs.h:22
int level() const
level() returns the level of CO.
InternalCF * getval() const
int l
Definition: cfEzgcd.cc:94
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40