My Project
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)
 
BOOLEAN convSingTrP (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 184 of file clapconv.cc.

185 {
186  return convFactoryAPSingAP_R(f,0,rPar(r),r);
187 }
FILE * f
Definition: checklibs.c:9
poly convFactoryAPSingAP_R(const CanonicalForm &f, int par_start, int var_start, const ring r)
Definition: clapconv.cc:173
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:604

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

285 {
286  poly a=NULL;
287  for( CFIterator i=f; i.hasTerms(); i++)
288  {
289  number n= convFactoryNSingAN( i.coeff(), r );
290  if (n_IsZero(n,r->cf->extRing->cf))
291  {
292  n_Delete(&n,r->cf->extRing->cf);
293  }
294  else
295  {
296  poly t= p_Init (r->cf->extRing);
297  pGetCoeff(t)=n;
298  p_SetExp(t,1,i.exp(),r->cf->extRing);
299  //p_Setm(t,r->cf->extRing);// not needed for rings with 1 variable
300  a=p_Add_q(a,t,r->cf->extRing);
301  }
302  }
303  if (a!=NULL)
304  {
305  if( r->cf->extRing != NULL )
306  if (r->cf->extRing->qideal->m[0]!=NULL)
307  {
308  poly l=r->cf->extRing->qideal->m[0];
309  if (p_GetExp(a,1,r->cf->extRing) >= p_GetExp(l,1,r->cf->extRing))
310  a = p_PolyDiv (a, l, FALSE, r->cf->extRing); // ???
311  }
312  }
313  return a;
314 }
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
static number convFactoryNSingAN(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:275
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
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
#define NULL
Definition: omList.c:12
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:1857
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:896
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
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
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1280

◆ convFactoryISingI()

int convFactoryISingI ( const CanonicalForm f)

Definition at line 142 of file clapconv.cc.

143 {
144  if (!f.isImm()) WerrorS("int overflow in det");
145  return f.intval();
146 }
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ convFactoryPSingP()

poly convFactoryPSingP ( const CanonicalForm f,
const ring  r 
)

Definition at line 40 of file clapconv.cc.

41 {
42  if (f.isZero()) return NULL;
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 * ADDRESS
Definition: auxiliary.h:119
static void conv_RecPP(const CanonicalForm &f, int *exp, sBucket_pt result, ring r)
Definition: clapconv.cc:54
return result
Definition: facAbsBiFact.cc:75
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:597
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96
void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:61

◆ convFactoryPSingTrP()

poly convFactoryPSingTrP ( const CanonicalForm f,
const ring  r 
)

Definition at line 366 of file clapconv.cc.

367 {
368  if (f.isZero()) return NULL;
369  int n = rVar(r)+1;
370  int * exp = (int*)omAlloc0(n*sizeof(int));
371  poly result = NULL;
372  convRecTrP( f, exp, result , rPar(r), r );
373  omFreeSize((ADDRESS)exp,n*sizeof(int));
374  return result;
375 }
static void convRecTrP(const CanonicalForm &f, int *exp, poly &result, int offs, const ring r)
Definition: clapconv.cc:378

◆ convSingAFactoryA()

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

Definition at line 232 of file clapconv.cc.

233 {
234  CanonicalForm result = 0;
235  int e;
236 
237  while ( p!=NULL )
238  {
240  if ( rField_is_Zp_a(r) )
241  {
242  term = n_Int( p_GetCoeff( p, r->cf->extRing ), r->cf->extRing->cf );
243  }
244  else
245  {
246  if ( SR_HDL(p_GetCoeff( p, r->cf->extRing )) & SR_INT )
247  term = SR_TO_INT(p_GetCoeff( p, r->cf->extRing )) ;
248  else
249  {
250  if ( p_GetCoeff( p, r->cf->extRing )->s == 3 )
251  {
252  mpz_t dummy;
253  mpz_init_set( dummy, (p_GetCoeff( p,r->cf->extRing )->z) );
254  term = make_cf( dummy );
255  }
256  else
257  {
258  // assume s==0 or s==1
259  mpz_t num, den;
260  On(SW_RATIONAL);
261  mpz_init_set( num, (p_GetCoeff( p, r->cf->extRing )->z) );
262  mpz_init_set( den, (p_GetCoeff( p, r->cf->extRing )->n) );
263  term = make_cf( num, den, ( p_GetCoeff( p, r->cf->extRing )->s != 1 ));
264  }
265  }
266  }
267  if ( (e = p_GetExp( p, 1, r->cf->extRing )) != 0 )
268  term *= power( a , e );
269  result += term;
270  p = pNext( p );
271  }
272  return result;
273 }
void On(int sw)
switches
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
CanonicalForm num(const CanonicalForm &f)
CanonicalForm den(const CanonicalForm &f)
int p
Definition: cfModGcd.cc:4080
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:30
factory's main class
Definition: canonicalform.h:86
Definition: int_poly.h:33
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
CanonicalForm FACTORY_PUBLIC make_cf(const mpz_ptr n)
Definition: singext.cc:66
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define pNext(p)
Definition: monomials.h:36
#define p_GetCoeff(p, r)
Definition: monomials.h:50
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:534
#define SR_HDL(A)
Definition: tgb.cc:35

◆ convSingAPFactoryAP()

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

Definition at line 148 of file clapconv.cc.

149 {
150  CanonicalForm result = 0;
151  int e, n = r-> N;
152  int off=rPar(r);
153 
154  if (!rField_is_Zp_a(r))
155  On(SW_RATIONAL);
156  while ( p!=NULL)
157  {
158  CanonicalForm term=convSingAFactoryA(((poly)p_GetCoeff(p, r->cf->extRing)),a, r);
159  for ( int i = 1; i <= n; i++ )
160  {
161  if ( (e = p_GetExp( p, i, r )) != 0 )
162  term *= CanonicalForm( Variable( i + off), e );
163  }
164  result += term;
165  pIter( p );
166  }
167  return result;
168 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
CanonicalForm convSingAFactoryA(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:232
factory's class for variables
Definition: factory.h:134
#define pIter(p)
Definition: monomials.h:37

◆ convSingPFactoryP()

CanonicalForm convSingPFactoryP ( poly  p,
const ring  r 
)

Definition at line 136 of file clapconv.cc.

137 {
138  BOOLEAN setChar=TRUE;
139  return convSingPFactoryP_intern(p,pLength(p),setChar,r);
140 }
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
static CanonicalForm convSingPFactoryP_intern(poly p, int l, BOOLEAN &setChar, const ring r)
Definition: clapconv.cc:103
static unsigned pLength(poly a)
Definition: p_polys.h:191

◆ convSingTrP()

BOOLEAN convSingTrP ( poly  p,
const ring  r 
)

Definition at line 352 of file clapconv.cc.

353 {
354  while ( p!=NULL )
355  {
356  n_Normalize(p_GetCoeff(p, r), r->cf);
357 
358  // test if denominator is constant
359  if (!p_IsConstant(DEN ((fraction)p_GetCoeff (p,r)),r->cf->extRing))
360  return FALSE;
361  pIter(p);
362  }
363  return TRUE;
364 }
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
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1971

◆ convSingTrPFactoryP()

CanonicalForm convSingTrPFactoryP ( poly  p,
const ring  r 
)

Definition at line 316 of file clapconv.cc.

317 {
318  CanonicalForm result = 0;
319  int e, n = rVar(r);
320  int offs = rPar(r);
321 
322  while ( p!=NULL )
323  {
324  //n_Normalize(p_GetCoeff(p, r), r->cf);
325 
326  // test if denominator is constant
327  if (!errorreported && !p_IsConstant(DEN ((fraction)p_GetCoeff (p,r)),r->cf->extRing))
328  WerrorS("conversion error: denominator!= 1");
329 
330  CanonicalForm term=convSingPFactoryP(NUM ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
331 
332  // if denominator is not NULL it should be a constant at this point
333  if (DEN ((fraction)p_GetCoeff(p,r)) != NULL)
334  {
335  CanonicalForm den= convSingPFactoryP(DEN ((fraction)p_GetCoeff(p, r)),r->cf->extRing);
336  if (rChar (r) == 0)
337  On (SW_RATIONAL);
338  term /= den;
339  }
340 
341  for ( int i = n; i > 0; i-- )
342  {
343  if ( (e = p_GetExp( p, i,r )) != 0 )
344  term = term * power( Variable( i + offs ), e );
345  }
346  result += term;
347  p = pNext( p );
348  }
349  return result;
350 }
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:136
VAR short errorreported
Definition: feFopen.cc:23
@ NUM
Definition: readcf.cc:170
int rChar(ring r)
Definition: ring.cc:714