My Project  UNKNOWN_GIT_VERSION
Functions
clapconv.h File Reference
#include "polys/monomials/ring.h"
#include "factory/factory.h"

Go to the source code of this file.

Functions

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)
 
poly convFactoryAPSingAP (const CanonicalForm &f, const ring r)
 
poly convFactoryAPSingAP_R (const CanonicalForm &f, int par_start, int var_start)
 
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)
 

Function Documentation

◆ convFactoryAPSingAP()

poly convFactoryAPSingAP ( const CanonicalForm f,
const ring  r 
)

Definition at line 152 of file clapconv.cc.

153 {
154  return convFactoryAPSingAP_R(f,0,rPar(r),r);
155 }

◆ convFactoryAPSingAP_R()

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

◆ convFactoryASingA()

poly convFactoryASingA ( const CanonicalForm f,
const ring  r 
)

Definition at line 253 of file clapconv.cc.

254 {
255  poly a=NULL;
256  for( CFIterator i=f; i.hasTerms(); i++)
257  {
258  number n= convFactoryNSingAN( i.coeff(), r );
259  if (n_IsZero(n,r->cf->extRing->cf))
260  {
261  n_Delete(&n,r->cf->extRing->cf);
262  }
263  else
264  {
265  poly t= p_Init (r->cf->extRing);
266  pGetCoeff(t)=n;
267  p_SetExp(t,1,i.exp(),r->cf->extRing);
268  //p_Setm(t,r->cf->extRing);// not needed for rings with 1 variable
269  a=p_Add_q(a,t,r->cf->extRing);
270  }
271  }
272  if (a!=NULL)
273  {
274  if( r->cf->extRing != NULL )
275  if (r->cf->extRing->qideal->m[0]!=NULL)
276  {
277  poly l=r->cf->extRing->qideal->m[0];
278  if (p_GetExp(a,1,r->cf->extRing) >= p_GetExp(l,1,r->cf->extRing))
279  a = p_PolyDiv (a, l, FALSE, r->cf->extRing); // ???
280  }
281  }
282  return a;
283 }

◆ convFactoryISingI()

int convFactoryISingI ( const CanonicalForm f)

Definition at line 111 of file clapconv.cc.

112 {
113  if (!f.isImm()) WerrorS("int overflow in det");
114  return f.intval();
115 }

◆ 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 }

◆ convFactoryPSingTrP()

poly convFactoryPSingTrP ( const CanonicalForm f,
const ring  r 
)

Definition at line 321 of file clapconv.cc.

322 {
323  int n = rVar(r)+1;
324  int * exp = (int*)omAlloc0(n*sizeof(int));
325  poly result = NULL;
326  convRecTrP( f, exp, result , rPar(r), r );
327  omFreeSize((ADDRESS)exp,n*sizeof(int));
328  return result;
329 }

◆ convSingAFactoryA()

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

Definition at line 201 of file clapconv.cc.

202 {
203  CanonicalForm result = 0;
204  int e;
205 
206  while ( p!=NULL )
207  {
209  if ( rField_is_Zp_a(r) )
210  {
211  term = n_Int( p_GetCoeff( p, r->cf->extRing ), r->cf->extRing->cf );
212  }
213  else
214  {
215  if ( SR_HDL(p_GetCoeff( p, r->cf->extRing )) & SR_INT )
216  term = SR_TO_INT(p_GetCoeff( p, r->cf->extRing )) ;
217  else
218  {
219  if ( p_GetCoeff( p, r->cf->extRing )->s == 3 )
220  {
221  mpz_t dummy;
222  mpz_init_set( dummy, (p_GetCoeff( p,r->cf->extRing )->z) );
223  term = make_cf( dummy );
224  }
225  else
226  {
227  // assume s==0 or s==1
228  mpz_t num, den;
229  On(SW_RATIONAL);
230  mpz_init_set( num, (p_GetCoeff( p, r->cf->extRing )->z) );
231  mpz_init_set( den, (p_GetCoeff( p, r->cf->extRing )->n) );
232  term = make_cf( num, den, ( p_GetCoeff( p, r->cf->extRing )->s != 1 ));
233  }
234  }
235  }
236  if ( (e = p_GetExp( p, 1, r->cf->extRing )) != 0 )
237  term *= power( a , e );
238  result += term;
239  p = pNext( p );
240  }
241  return result;
242 }

◆ convSingAPFactoryAP()

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

Definition at line 117 of file clapconv.cc.

118 {
119  CanonicalForm result = 0;
120  int e, n = r-> N;
121  int off=rPar(r);
122 
123  if (!rField_is_Zp_a(r))
124  On(SW_RATIONAL);
125  while ( p!=NULL)
126  {
127  CanonicalForm term=convSingAFactoryA(((poly)p_GetCoeff(p, r->cf->extRing)),a, r);
128  for ( int i = 1; i <= n; i++ )
129  {
130  if ( (e = p_GetExp( p, i, r )) != 0 )
131  term *= power( Variable( i + off), e );
132  }
133  result += term;
134  pIter( p );
135  }
136  return result;
137 }

◆ convSingPFactoryP()

CanonicalForm convSingPFactoryP ( poly  p,
const ring  r 
)

Definition at line 86 of file clapconv.cc.

87 {
89  int e, n = rVar(r);
90  BOOLEAN setChar=TRUE;
91 
92  p=pReverse(p);
93  poly op=p;
94  while ( p!=NULL )
95  {
96  CanonicalForm term=r->cf->convSingNFactoryN(pGetCoeff( p ),setChar, r->cf);
97  if (errorreported) break;
98  setChar=FALSE;
99  for ( int i = n; i >0; i-- )
100  {
101  if ( (e = p_GetExp( p, i, r)) != 0 )
102  term *= CanonicalForm( Variable( i ), e );
103  }
104  result += term;
105  pIter( p );
106  }
107  op=pReverse(op);
108  return result;
109 }

◆ convSingTrPFactoryP()

CanonicalForm convSingTrPFactoryP ( poly  p,
const ring  r 
)

Definition at line 285 of file clapconv.cc.

286 {
287  CanonicalForm result = 0;
288  int e, n = rVar(r);
289  int offs = rPar(r);
290 
291  while ( p!=NULL )
292  {
293  n_Normalize(p_GetCoeff(p, r), r->cf);
294 
295  // test if denominator is constant
296  if (!p_IsConstantPoly(DEN ((fraction)p_GetCoeff (p,r)),r->cf->extRing) && !errorreported)
297  WerrorS("conversion error: denominator!= 1");
298 
299  CanonicalForm term=convSingPFactoryP(NUM ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
300 
301  // if denominator is not NULL it should be a constant at this point
302  if (DEN ((fraction)p_GetCoeff(p,r)) != NULL)
303  {
304  CanonicalForm den= convSingPFactoryP(DEN ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
305  if (rChar (r) == 0)
306  On (SW_RATIONAL);
307  term /= den;
308  }
309 
310  for ( int i = n; i > 0; i-- )
311  {
312  if ( (e = p_GetExp( p, i,r )) != 0 )
313  term = term * power( Variable( i + offs ), e );
314  }
315  result += term;
316  p = pNext( p );
317  }
318  return result;
319 }
FALSE
#define FALSE
Definition: auxiliary.h:94
SW_RATIONAL
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
p_GetCoeff
#define p_GetCoeff(p, r)
Definition: monomials.h:48
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:458
f
FILE * f
Definition: checklibs.c:9
errorreported
short errorreported
Definition: feFopen.cc:23
CFIterator
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
result
return result
Definition: facAbsBiFact.cc:76
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
num
CanonicalForm num(const CanonicalForm &f)
Definition: canonicalform.h:330
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: canonicalform.cc:1837
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:454
make_cf
CanonicalForm make_cf(const mpz_ptr n)
Definition: singext.cc:66
convSingAFactoryA
CanonicalForm convSingAFactoryA(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:201
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
rField_is_Zp_a
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:519
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:463
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:577
CanonicalForm
factory's main class
Definition: canonicalform.h:77
term
Definition: int_poly.h:33
p_SetExp
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:477
convRecTrP
static void convRecTrP(const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
Definition: clapconv.cc:332
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:581
conv_RecPP
static void conv_RecPP(const CanonicalForm &f, int *exp, sBucket_pt result, ring r)
Definition: clapconv.cc:54
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
rChar
int rChar(ring r)
Definition: ring.cc:685
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
convFactoryNSingAN
static number convFactoryNSingAN(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:244
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96
pIter
#define pIter(p)
Definition: monomials.h:35
rPar
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:588
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1240
p_PolyDiv
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:1814
den
CanonicalForm den(const CanonicalForm &f)
Definition: canonicalform.h:333
sBucket
Definition: sbuckets.cc:29
SR_INT
#define SR_INT
Definition: longrat.h:65
convSingPFactoryP
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:86
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
SR_TO_INT
#define SR_TO_INT(SR)
Definition: longrat.h:67
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:878
Variable
factory's class for variables
Definition: factory.h:117
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
SR_HDL
#define SR_HDL(A)
Definition: tgb.cc:35
NULL
#define NULL
Definition: omList.c:9
l
int l
Definition: cfEzgcd.cc:93
n_Int
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:546
p
int p
Definition: cfModGcd.cc:4019
p_IsConstantPoly
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1921
NUM
Definition: readcf.cc:173
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:42
convFactoryAPSingAP_R
poly convFactoryAPSingAP_R(const CanonicalForm &f, int par_start, int var_start, const ring r)
Definition: clapconv.cc:142
pNext
#define pNext(p)
Definition: monomials.h:34
pReverse
static poly pReverse(poly p)
Definition: p_polys.h:327
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
On
void On(int sw)
switches
Definition: canonicalform.cc:1898
sBucketDestroyMerge
void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:59