My Project  debian-1:4.1.1-p2+ds-4build2
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 153 of file clapconv.cc.

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

◆ 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 254 of file clapconv.cc.

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

◆ convFactoryISingI()

int convFactoryISingI ( const CanonicalForm f)

Definition at line 112 of file clapconv.cc.

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

◆ 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 322 of file clapconv.cc.

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

◆ convSingAFactoryA()

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

Definition at line 202 of file clapconv.cc.

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

◆ convSingAPFactoryAP()

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

Definition at line 118 of file clapconv.cc.

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

◆ 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  {
97  term=r->cf->convSingNFactoryN(pGetCoeff( p ),setChar, r->cf);
98  if (errorreported) break;
99  setChar=FALSE;
100  for ( int i = n; i >0; i-- )
101  {
102  if ( (e = p_GetExp( p, i, r)) != 0 )
103  term *= power( Variable( i ), e );
104  }
105  result += term;
106  pIter( p );
107  }
108  op=pReverse(op);
109  return result;
110 }

◆ convSingTrPFactoryP()

CanonicalForm convSingTrPFactoryP ( poly  p,
const ring  r 
)

Definition at line 286 of file clapconv.cc.

287 {
288  CanonicalForm result = 0;
289  int e, n = rVar(r);
290  int offs = rPar(r);
291 
292  while ( p!=NULL )
293  {
294  n_Normalize(p_GetCoeff(p, r), r->cf);
295 
296  // test if denominator is constant
297  if (!p_IsConstantPoly(DEN ((fraction)p_GetCoeff (p,r)),r->cf->extRing) && !errorreported)
298  WerrorS("conversion error: denominator!= 1");
299 
300  CanonicalForm term=convSingPFactoryP(NUM ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
301 
302  // if denominator is not NULL it should be a constant at this point
303  if (DEN ((fraction)p_GetCoeff(p,r)) != NULL)
304  {
305  CanonicalForm den= convSingPFactoryP(DEN ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
306  if (rChar (r) == 0)
307  On (SW_RATIONAL);
308  term /= den;
309  }
310 
311  for ( int i = n; i > 0; i-- )
312  {
313  if ( (e = p_GetExp( p, i,r )) != 0 )
314  term = term * power( Variable( i + offs ), e );
315  }
316  result += term;
317  p = pNext( p );
318  }
319  return result;
320 }
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:57
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:469
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:456
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:202
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
rField_is_Zp_a
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:521
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
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:579
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:488
convRecTrP
static void convRecTrP(const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
Definition: clapconv.cc:333
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
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:688
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
convFactoryNSingAN
static number convFactoryNSingAN(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:245
sBucketCreate
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:99
pIter
#define pIter(p)
Definition: monomials.h:44
rPar
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
p_Init
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1266
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:1817
den
CanonicalForm den(const CanonicalForm &f)
Definition: canonicalform.h:333
sBucket
Definition: sbuckets.cc:33
SR_INT
#define SR_INT
Definition: longrat.h:68
convSingPFactoryP
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:86
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
SR_TO_INT
#define SR_TO_INT(SR)
Definition: longrat.h:70
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
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:10
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:548
p
int p
Definition: cfModGcd.cc:4019
p_IsConstantPoly
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1937
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:51
convFactoryAPSingAP_R
poly convFactoryAPSingAP_R(const CanonicalForm &f, int par_start, int var_start, const ring r)
Definition: clapconv.cc:143
pNext
#define pNext(p)
Definition: monomials.h:43
pReverse
static poly pReverse(poly p)
Definition: p_polys.h:335
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
On
void On(int sw)
switches
Definition: canonicalform.cc:1898
sBucketDestroyMerge
void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:61