Functions
facAlgFuncUtil.cc File Reference

This file provides utility functions to factorize polynomials over alg. More...

#include "config.h"
#include "cf_assert.h"
#include "canonicalform.h"
#include "facAlgFuncUtil.h"
#include "cfCharSetsUtil.h"
#include "cf_random.h"
#include "cf_irred.h"
#include "cf_algorithm.h"
#include "cf_util.h"
#include "cf_iter.h"

Go to the source code of this file.

Functions

CFFList append (const CFFList &Inputlist, const CFFactor &TheFactor)
 
CFFList merge (const CFFList &Inputlist1, const CFFList &Inputlist2)
 
Varlist varsInAs (const Varlist &uord, const CFList &Astar)
 
CanonicalForm generateMipo (int degOfExt)
 
CanonicalForm alg_lc (const CanonicalForm &f)
 
CanonicalForm alg_LC (const CanonicalForm &f, int lev)
 
CanonicalForm subst (const CanonicalForm &f, const CFList &a, const CFList &b, const CanonicalForm &Rstar, bool isFunctionField)
 
CanonicalForm backSubst (const CanonicalForm &F, const CFList &a, const CFList &b)
 
void deflateDegree (const CanonicalForm &F, int &pExp, int n)
 
CanonicalForm deflatePoly (const CanonicalForm &F, int exp)
 
CanonicalForm deflatePoly (const CanonicalForm &F, int exps, int n)
 
CanonicalForm inflatePoly (const CanonicalForm &F, int exp)
 
CanonicalForm inflatePoly (const CanonicalForm &F, int exps, int n)
 
void multiplicity (CFFList &factors, const CanonicalForm &F, const CFList &as)
 
int hasAlgVar (const CanonicalForm &f, const Variable &v)
 
int hasVar (const CanonicalForm &f, const Variable &v)
 
int hasAlgVar (const CanonicalForm &f)
 
void psqr (const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &q, CanonicalForm &r, CanonicalForm &multiplier, const Variable &x)
 pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r More...
 
CanonicalForm Sprem (const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &m, CanonicalForm &q)
 
CanonicalForm divide (const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
 
bool isInseparable (const CFList &Astar)
 
int getDegOfExt (IntList &degreelist, int n)
 
CanonicalForm QuasiInverse (const CanonicalForm &f, const CanonicalForm &g, const Variable &x)
 
CanonicalForm evaluate (const CanonicalForm &f, const CanonicalForm &g, const CanonicalForm &h, const CanonicalForm &powH)
 
CanonicalForm evaluate (const CanonicalForm &f, const CanonicalForm &g, const CanonicalForm &h, const CanonicalForm &powH, const Variable &v)
 evaluate f at g/h at v such that powH*f is integral i.e. powH is assumed to be h^degree(f,v) More...
 

Detailed Description

This file provides utility functions to factorize polynomials over alg.

function fields

Note
some of the code is code from libfac or derived from code from libfac. Libfac is written by M. Messollen. See also COPYING for license information and README for general information on characteristic sets.
Author
Martin Lee

Definition in file facAlgFuncUtil.cc.

Function Documentation

Definition at line 100 of file facAlgFuncUtil.cc.

101 {
102  if (f.level()>0)
103  {
104  return alg_lc(f.LC());
105  }
106 
107  return f;
108 }
f
Definition: cfModGcd.cc:4022
CanonicalForm alg_lc(const CanonicalForm &f)
int level() const
level() returns the level of CO.
CanonicalForm LC() const
CanonicalForm alg_LC ( const CanonicalForm f,
int  lev 
)

Definition at line 110 of file facAlgFuncUtil.cc.

111 {
113  while (result.level() > lev)
114  result= LC (result);
115  return result;
116 }
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
int level() const
level() returns the level of CO.
CanonicalForm LC(const CanonicalForm &f)
return result
Definition: facAbsBiFact.cc:76
CFFList append ( const CFFList Inputlist,
const CFFactor TheFactor 
)

Definition at line 32 of file facAlgFuncUtil.cc.

33 {
34  CFFList Outputlist;
35  CFFactor copy;
37  int exp=0;
38 
39  for (i= Inputlist; i.hasItem() ; i++)
40  {
41  copy= i.getItem();
42  if (copy.factor() == TheFactor.factor())
43  exp += copy.exp();
44  else
45  Outputlist.append(copy);
46  }
47  Outputlist.append (CFFactor (TheFactor.factor(), exp + TheFactor.exp()));
48  return Outputlist;
49 }
int exp() const
Definition: ftmpl_factor.h:33
CFArray copy(const CFList &list)
write elements of list into an array
T factor() const
Definition: ftmpl_factor.h:32
int i
Definition: cfEzgcd.cc:123
T & getItem() const
Definition: ftmpl_list.cc:431
p exp[i]
Definition: DebugPrint.cc:39
void append(const T &)
Definition: ftmpl_list.cc:256
CanonicalForm backSubst ( const CanonicalForm F,
const CFList a,
const CFList b 
)

Definition at line 192 of file facAlgFuncUtil.cc.

193 {
194  ASSERT (a.length() == b.length() - 1, "wrong length of lists in backSubst");
196  Variable tmp;
197  CFList tmp2= b;
198  tmp= tmp2.getLast().mvar();
199  tmp2.removeLast();
200  for (CFListIterator iter= a; iter.hasItem(); iter++)
201  {
202  result= result (tmp+iter.getItem()*tmp2.getLast().mvar(), tmp);
203  tmp= tmp2.getLast().mvar();
204  tmp2.removeLast();
205  }
206  return result;
207 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory's class for variables
Definition: variable.h:32
CFFListIterator iter
Definition: facAbsBiFact.cc:54
factory's main class
Definition: canonicalform.h:72
void removeLast()
Definition: ftmpl_list.cc:317
int length() const
Definition: ftmpl_list.cc:273
CFList tmp2
Definition: facFqBivar.cc:70
T & getItem() const
Definition: ftmpl_list.cc:431
T getLast() const
Definition: ftmpl_list.cc:309
#define ASSERT(expression, message)
Definition: cf_assert.h:99
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76
void deflateDegree ( const CanonicalForm F,
int pExp,
int  n 
)

Definition at line 209 of file facAlgFuncUtil.cc.

210 {
211  if (n == 0 || n > F.level())
212  {
213  pExp= -1;
214  return;
215  }
216  if (F.level() == n)
217  {
218  ASSERT (F.deriv().isZero(), "derivative of F is not zero");
219  int termCount=0;
220  CFIterator i= F;
221  for (; i.hasTerms(); i++)
222  {
223  if (i.exp() != 0)
224  termCount++;
225  }
226 
227  int j= 1;
228  i= F;
229  for (;j < termCount; j++, i++)
230  ;
231 
232  int exp= i.exp();
233  int count= 0;
234  int p= getCharacteristic();
235  while ((exp >= p) && (exp != 0) && (exp % p == 0))
236  {
237  exp /= p;
238  count++;
239  }
240  pExp= count;
241  }
242  else
243  {
244  CFIterator i= F;
245  deflateDegree (i.coeff(), pExp, n);
246  i++;
247  int tmp= pExp;
248  for (; i.hasTerms(); i++)
249  {
250  deflateDegree (i.coeff(), pExp, n);
251  if (tmp == -1)
252  tmp= pExp;
253  else if (tmp != -1 && pExp != -1)
254  pExp= (pExp < tmp) ? pExp : tmp;
255  else
256  pExp= tmp;
257  }
258  }
259 }
int status int void size_t count
Definition: si_signals.h:58
return P p
Definition: myNF.cc:203
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.
int getCharacteristic()
Definition: cf_char.cc:51
int level() const
level() returns the level of CO.
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
void deflateDegree(const CanonicalForm &F, int &pExp, int n)
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
#define ASSERT(expression, message)
Definition: cf_assert.h:99
p exp[i]
Definition: DebugPrint.cc:39
CanonicalForm deflatePoly ( const CanonicalForm F,
int  exp 
)

Definition at line 261 of file facAlgFuncUtil.cc.

262 {
263  if (exp == 0)
264  return F;
265  int p= getCharacteristic();
266  int pToExp= ipower (p, exp);
267  Variable x=F.mvar();
269  for (CFIterator i= F; i.hasTerms(); i++)
270  result += i.coeff()*power (x, i.exp()/pToExp);
271  return result;
272 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
return P p
Definition: myNF.cc:203
factory's class for variables
Definition: variable.h:32
factory's main class
Definition: canonicalform.h:72
int getCharacteristic()
Definition: cf_char.cc:51
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
int ipower(int b, int m)
int ipower ( int b, int m )
Definition: cf_util.cc:25
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39
return result
Definition: facAbsBiFact.cc:76
CanonicalForm deflatePoly ( const CanonicalForm F,
int  exps,
int  n 
)

Definition at line 274 of file facAlgFuncUtil.cc.

275 {
276  if (n == 0 || exps <= 0 || F.level() < n)
277  return F;
278  if (F.level() == n)
279  return deflatePoly (F, exps);
280  else
281  {
283  for (CFIterator i= F; i.hasTerms(); i++)
284  result += deflatePoly (i.coeff(), exps, n)*power(F.mvar(), i.exp());
285  return result;
286  }
287 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
factory's main class
Definition: canonicalform.h:72
CanonicalForm deflatePoly(const CanonicalForm &F, int exp)
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
return result
Definition: facAbsBiFact.cc:76
CanonicalForm divide ( const CanonicalForm ff,
const CanonicalForm f,
const CFList as 
)

Definition at line 523 of file facAlgFuncUtil.cc.

524 {
525  CanonicalForm r, m, q;
526 
527  if (f.inCoeffDomain())
528  {
529  bool isRat= isOn(SW_RATIONAL);
530  if (getCharacteristic() == 0)
531  On(SW_RATIONAL);
532  q= ff/f;
533  if (!isRat && getCharacteristic() == 0)
534  Off(SW_RATIONAL);
535  }
536  else
537  r= Sprem (ff, f, m, q);
538 
539  r= Prem (q, as);
540  return r;
541 }
void Off(int sw)
switches
bool inCoeffDomain() const
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
int getCharacteristic()
Definition: cf_char.cc:51
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
int m
Definition: cfEzgcd.cc:119
bool isOn(int sw)
switches
void On(int sw)
switches
CanonicalForm Prem(const CanonicalForm &F, const CanonicalForm &G)
pseudo remainder of F by G with certain factors of LC (g) cancelled
CanonicalForm Sprem(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &m, CanonicalForm &q)

Definition at line 663 of file facAlgFuncUtil.cc.

665 {
666  if (f.inCoeffDomain())
667  return f;
668  CFIterator i= f;
669  int lastExp = i.exp();
670  CanonicalForm result = i.coeff()*powH;
671  i++;
672  while (i.hasTerms())
673  {
674  int i_exp= i.exp();
675  if ((lastExp - i_exp) == 1)
676  {
677  result *= g;
678  result /= h;
679  }
680  else
681  {
682  result *= power (g, lastExp - i_exp);
683  result /= power (h, lastExp - i_exp);
684  }
685  result += i.coeff()*powH;
686  lastExp = i_exp;
687  i++;
688  }
689  if (lastExp != 0)
690  {
691  result *= power (g, lastExp);
692  result /= power (h, lastExp);
693  }
694  return result;
695 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
bool inCoeffDomain() const
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
g
Definition: cfModGcd.cc:4031
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
static Poly * h
Definition: janet.cc:978
return result
Definition: facAbsBiFact.cc:76

evaluate f at g/h at v such that powH*f is integral i.e. powH is assumed to be h^degree(f,v)

Definition at line 700 of file facAlgFuncUtil.cc.

703 {
704  if (f.inCoeffDomain())
705  {
706  return f*powH;
707  }
708 
709  Variable x = f.mvar();
710  if ( v > x )
711  return f*powH;
712  else if ( v == x )
713  return evaluate (f, g, h, powH);
714 
715  // v is less than main variable of f
717  for (CFIterator i= f; i.hasTerms(); i++)
718  result += evaluate (i.coeff(), g, h, powH, v)*power (x, i.exp());
719  return result;
720 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CanonicalForm evaluate(const CanonicalForm &f, const CanonicalForm &g, const CanonicalForm &h, const CanonicalForm &powH)
bool inCoeffDomain() const
factory's class for variables
Definition: variable.h:32
factory's main class
Definition: canonicalform.h:72
g
Definition: cfModGcd.cc:4031
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
Variable x
Definition: cfModGcd.cc:4023
static Poly * h
Definition: janet.cc:978
return result
Definition: facAbsBiFact.cc:76
CanonicalForm generateMipo ( int  degOfExt)

Definition at line 90 of file facAlgFuncUtil.cc.

91 {
92 #ifndef HAVE_NTL
93  FFRandom gen;
94  return find_irreducible (degOfExt, gen, Variable (1));
95 #else
96  return randomIrredpoly (degOfExt, Variable (1));
97 #endif
98 }
factory's class for variables
Definition: variable.h:32
generate random elements in F_p
Definition: cf_random.h:43
CanonicalForm find_irreducible(int deg, CFRandom &gen, const Variable &x)
generate a random irreducible polynomial in x of degree deg
Definition: cf_irred.cc:26
CanonicalForm randomIrredpoly(int i, const Variable &x)
computes a random monic irreducible univariate polynomial in x over Fp of degree i via NTL ...
Definition: cf_irred.cc:42
int getDegOfExt ( IntList degreelist,
int  n 
)

Definition at line 566 of file facAlgFuncUtil.cc.

567 {
568  int charac= getCharacteristic();
569  setCharacteristic(0); // need it for k !
570  int k= 1, m= 1, length= degreelist.length();
572 
573  for (i= degreelist; i.hasItem(); i++)
574  m= m*i.getItem();
575  int q= charac;
576  while (q <= ((n*m)*(n*m)/2))
577  {
578  k= k+1;
579  q= q*charac;
580  }
581  int l= 0;
582  do
583  {
584  for (i= degreelist; i.hasItem(); i++)
585  {
586  l= l + 1;
587  if (igcd (k, i.getItem()) == 1)
588  {
589  if (l == length)
590  {
591  setCharacteristic (charac);
592  return k;
593  }
594  }
595  else
596  break;
597  }
598  k= k + 1;
599  l= 0;
600  }
601  while (1);
602 }
int igcd(int a, int b)
Definition: cf_util.cc:51
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
int k
Definition: cfEzgcd.cc:93
void setCharacteristic(int c)
Definition: cf_char.cc:23
int getCharacteristic()
Definition: cf_char.cc:51
int m
Definition: cfEzgcd.cc:119
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
T & getItem() const
Definition: ftmpl_list.cc:431
int l
Definition: cfEzgcd.cc:94
int hasAlgVar ( const CanonicalForm f,
const Variable v 
)

Definition at line 345 of file facAlgFuncUtil.cc.

346 {
347  if (f.inBaseDomain())
348  return 0;
349  if (f.inCoeffDomain())
350  {
351  if (f.mvar() == v)
352  return 1;
353  return hasAlgVar (f.LC(), v);
354  }
355  if (f.inPolyDomain())
356  {
357  if (hasAlgVar(f.LC(), v))
358  return 1;
359  for (CFIterator i= f; i.hasTerms(); i++)
360  {
361  if (hasAlgVar (i.coeff(), v))
362  return 1;
363  }
364  }
365  return 0;
366 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
bool inPolyDomain() const
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
CanonicalForm LC() const
bool inBaseDomain() const
int hasAlgVar(const CanonicalForm &f, const Variable &v)
int hasAlgVar ( const CanonicalForm f)

Definition at line 393 of file facAlgFuncUtil.cc.

394 {
395  if (f.inBaseDomain())
396  return 0;
397  if (f.inCoeffDomain())
398  {
399  if (f.level() != 0)
400  return 1;
401  return hasAlgVar(f.LC());
402  }
403  if (f.inPolyDomain())
404  {
405  if (hasAlgVar(f.LC()))
406  return 1;
407  for (CFIterator i= f; i.hasTerms(); i++)
408  {
409  if (hasAlgVar (i.coeff()))
410  return 1;
411  }
412  }
413  return 0;
414 }
bool inCoeffDomain() const
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
bool inPolyDomain() const
CanonicalForm LC() const
bool inBaseDomain() const
int hasAlgVar(const CanonicalForm &f, const Variable &v)
int hasVar ( const CanonicalForm f,
const Variable v 
)

Definition at line 368 of file facAlgFuncUtil.cc.

369 {
370  if (f.inBaseDomain())
371  return 0;
372  if (f.inCoeffDomain())
373  {
374  if (f.mvar() == v)
375  return 1;
376  return hasAlgVar (f.LC(), v);
377  }
378  if (f.inPolyDomain())
379  {
380  if (f.mvar() == v)
381  return 1;
382  if (hasVar (f.LC(), v))
383  return 1;
384  for (CFIterator i= f; i.hasTerms(); i++)
385  {
386  if (hasVar (i.coeff(), v))
387  return 1;
388  }
389  }
390  return 0;
391 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
bool inPolyDomain() const
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
CanonicalForm LC() const
bool inBaseDomain() const
int hasAlgVar(const CanonicalForm &f, const Variable &v)
int hasVar(const CanonicalForm &f, const Variable &v)
CanonicalForm inflatePoly ( const CanonicalForm F,
int  exp 
)

Definition at line 289 of file facAlgFuncUtil.cc.

290 {
291  if (exp == 0)
292  return F;
293  int p= getCharacteristic();
294  int pToExp= ipower (p, exp);
295  Variable x=F.mvar();
297  for (CFIterator i= F; i.hasTerms(); i++)
298  result += i.coeff()*power (x, i.exp()*pToExp);
299  return result;
300 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
return P p
Definition: myNF.cc:203
factory's class for variables
Definition: variable.h:32
factory's main class
Definition: canonicalform.h:72
int getCharacteristic()
Definition: cf_char.cc:51
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
int ipower(int b, int m)
int ipower ( int b, int m )
Definition: cf_util.cc:25
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39
return result
Definition: facAbsBiFact.cc:76
CanonicalForm inflatePoly ( const CanonicalForm F,
int  exps,
int  n 
)

Definition at line 302 of file facAlgFuncUtil.cc.

303 {
304  if (n == 0 || exps <= 0 || F.level() < n)
305  return F;
306  if (F.level() == n)
307  return inflatePoly (F, exps);
308  else
309  {
311  for (CFIterator i= F; i.hasTerms(); i++)
312  result += inflatePoly (i.coeff(), exps, n)*power(F.mvar(), i.exp());
313  return result;
314  }
315 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
factory's main class
Definition: canonicalform.h:72
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CanonicalForm inflatePoly(const CanonicalForm &F, int exp)
return result
Definition: facAbsBiFact.cc:76
bool isInseparable ( const CFList Astar)

Definition at line 545 of file facAlgFuncUtil.cc.

546 {
547  CanonicalForm elem;
548 
549  if (Astar.length() == 0)
550  return false;
551  for (CFListIterator i= Astar; i.hasItem(); i++)
552  {
553  elem= i.getItem();
554  if (elem.deriv().isZero())
555  return true;
556  }
557  return false;
558 }
factory's main class
Definition: canonicalform.h:72
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
CFFList merge ( const CFFList Inputlist1,
const CFFList Inputlist2 
)

Definition at line 52 of file facAlgFuncUtil.cc.

53 {
54  CFFList Outputlist;
56 
57  for (i= Inputlist1; i.hasItem(); i++)
58  Outputlist= append (Outputlist, i.getItem());
59  for (i= Inputlist2; i.hasItem() ; i++)
60  Outputlist= append (Outputlist, i.getItem());
61 
62  return Outputlist;
63 }
CFFList append(const CFFList &Inputlist, const CFFactor &TheFactor)
int i
Definition: cfEzgcd.cc:123
T & getItem() const
Definition: ftmpl_list.cc:431
void multiplicity ( CFFList factors,
const CanonicalForm F,
const CFList as 
)

Definition at line 318 of file facAlgFuncUtil.cc.

319 {
320  CanonicalForm G= F;
321  Variable x= F.mvar();
322  CanonicalForm q, r;
323  int count= -1;
324  for (CFFListIterator iter=factors; iter.hasItem(); iter++)
325  {
326  count= -1;
327  if (iter.getItem().factor().inCoeffDomain())
328  continue;
329  while (1)
330  {
331  psqr (G, iter.getItem().factor(), q, r, x);
332 
333  q= Prem (q, as);
334  r= Prem (r, as);
335  if (!r.isZero())
336  break;
337  count++;
338  G= q;
339  }
340  iter.getItem()= CFFactor (iter.getItem().factor(),
341  iter.getItem().exp() + count);
342  }
343 }
int status int void size_t count
Definition: si_signals.h:58
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory's class for variables
Definition: variable.h:32
CFFListIterator iter
Definition: facAbsBiFact.cc:54
factory's main class
Definition: canonicalform.h:72
void psqr(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &q, CanonicalForm &r, CanonicalForm &multiplier, const Variable &x)
pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r
static TreeM * G
Definition: janet.cc:38
const ring r
Definition: syzextra.cc:208
T & getItem() const
Definition: ftmpl_list.cc:431
Factor< CanonicalForm > CFFactor
Variable x
Definition: cfModGcd.cc:4023
CanonicalForm Prem(const CanonicalForm &F, const CanonicalForm &G)
pseudo remainder of F by G with certain factors of LC (g) cancelled
void psqr ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r,
CanonicalForm multiplier,
const Variable x 
)

pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r

Definition at line 418 of file facAlgFuncUtil.cc.

420 {
421  ASSERT( x.level() > 0, "type error: polynomial variable expected" );
422  ASSERT( ! g.isZero(), "math error: division by zero" );
423 
424  // swap variables such that x's level is larger or equal
425  // than both f's and g's levels.
426  Variable X;
427  if (f.level() > g.level())
428  X= f.mvar();
429  else
430  X= g.mvar();
431  if (X.level() < x.level())
432  X= x;
433  CanonicalForm F= swapvar (f, x, X);
434  CanonicalForm G= swapvar (g, x, X);
435 
436  // now, we have to calculate the pseudo remainder of F and G
437  // w.r.t. X
438  int fDegree= degree (F, X);
439  int gDegree= degree (G, X);
440  if (fDegree < 0 || fDegree < gDegree)
441  {
442  q= 0;
443  r= f;
444  }
445  else
446  {
447  CanonicalForm LCG= LC (G, X);
448  multiplier= power (LCG, fDegree - gDegree + 1);
449  divrem (multiplier*F, G, q, r);
450  q= swapvar (q, x, X);
451  r= swapvar (r, x, X);
452  }
453 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int level() const
Definition: variable.h:49
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
f
Definition: cfModGcd.cc:4022
factory's class for variables
Definition: variable.h:32
factory's main class
Definition: canonicalform.h:72
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
static TreeM * G
Definition: janet.cc:38
int level() const
level() returns the level of CO.
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int degree(const CanonicalForm &f)
CanonicalForm LC(const CanonicalForm &f)
void divrem(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &q, CanonicalForm &r)
CanonicalForm QuasiInverse ( const CanonicalForm f,
const CanonicalForm g,
const Variable x 
)

Definition at line 605 of file facAlgFuncUtil.cc.

607 {
608  CanonicalForm pi, pi1, q, t0, t1, Hi, bi, pi2;
609  bool isRat= isOn (SW_RATIONAL);
610  pi= f;
611  pi1= g;
612  if (isRat)
613  {
614  pi *= bCommonDen (pi);
615  pi1 *= bCommonDen (pi1);
616  }
617  CanonicalForm m,tmp;
618  if (isRat && getCharacteristic() == 0)
619  Off (SW_RATIONAL);
620 
621  pi= pi/content (pi,x);
622  pi1= pi1/content (pi1,x);
623 
624  t0= 0;
625  t1= 1;
626  bi= 1;
627 
628  int delta= degree (f, x) - degree (g, x);
629  Hi= power (LC (pi1, x), delta);
630  if ( (delta+1) % 2 )
631  bi = 1;
632  else
633  bi = -1;
634 
635  while (degree (pi1,x) > 0)
636  {
637  psqr (pi, pi1, q, pi2, m, x);
638  pi2 /= bi;
639 
640  tmp= t1;
641  t1= t0*m - t1*q;
642  t0= tmp;
643  t1 /= bi;
644  pi= pi1;
645  pi1= pi2;
646  if (degree (pi1, x) > 0)
647  {
648  delta= degree (pi, x) - degree (pi1, x);
649  if ((delta + 1) % 2)
650  bi= LC (pi, x)*power (Hi, delta);
651  else
652  bi= -LC (pi, x)*power (Hi, delta);
653  Hi= power (LC (pi1, x), delta)/power (Hi, delta - 1);
654  }
655  }
656  t1 /= gcd (pi1, t1);
657  if (isRat && getCharacteristic() == 0)
658  On (SW_RATIONAL);
659  return t1;
660 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
void Off(int sw)
switches
f
Definition: cfModGcd.cc:4022
factory's main class
Definition: canonicalform.h:72
g
Definition: cfModGcd.cc:4031
void psqr(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &q, CanonicalForm &r, CanonicalForm &multiplier, const Variable &x)
pseudo division of f and g wrt. x s.t. multiplier*f=q*g+r
bool delta(X x, Y y, D d)
Definition: TestSuite.h:160
int getCharacteristic()
Definition: cf_char.cc:51
CanonicalForm content(const CanonicalForm &)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
int m
Definition: cfEzgcd.cc:119
bool isOn(int sw)
switches
void On(int sw)
switches
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
#define pi
Definition: libparse.cc:1143
int gcd(int a, int b)
Definition: walkSupport.cc:839
int degree(const CanonicalForm &f)
CanonicalForm LC(const CanonicalForm &f)

Definition at line 456 of file facAlgFuncUtil.cc.

458 {
459  CanonicalForm ff, gg, l, test, retvalue;
460  int df, dg,n;
461  bool reord;
462  Variable vf, vg, v;
463 
464  if ((vf = f.mvar()) < (vg = g.mvar()))
465  {
466  m= 0;
467  q= 0;
468  return f;
469  }
470  else
471  {
472  if ( vf == vg )
473  {
474  ff= f;
475  gg= g;
476  reord= false;
477  v= vg; // == x
478  }
479  else
480  {
481  v= Variable (f.level() + 1);
482  ff= swapvar (f, vg, v); // == r
483  gg= swapvar (g, vg, v); // == v
484  reord=true;
485  }
486  dg= degree (gg, v); // == dv
487  df= degree (ff, v); // == dr
488  if (dg <= df)
489  {
490  l= LC (gg);
491  gg= gg - LC(gg)*power(v,dg);
492  }
493  else
494  l = 1;
495  n= 0;
496  while ((dg <= df) && (!ff.isZero()))
497  {
498  test= gg*LC (ff)*power (v, df - dg);
499  if (df == 0)
500  ff= 0;
501  else
502  ff= ff - LC(ff)*power(v,df);
503  ff= l*ff - test;
504  df= degree (ff, v);
505  n++;
506  }
507 
508  if (reord)
509  retvalue= swapvar (ff, vg, v);
510  else
511  retvalue= ff;
512 
513  m= power (l, n);
514  if (fdivides (g, m*f - retvalue))
515  q= (m*f - retvalue)/g;
516  else
517  q= 0;
518  return retvalue;
519  }
520 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
f
Definition: cfModGcd.cc:4022
factory's class for variables
Definition: variable.h:32
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
factory's main class
Definition: canonicalform.h:72
g
Definition: cfModGcd.cc:4031
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
int level() const
level() returns the level of CO.
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
CanonicalForm test
Definition: cfModGcd.cc:4037
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int degree(const CanonicalForm &f)
CanonicalForm LC(const CanonicalForm &f)
int l
Definition: cfEzgcd.cc:94
CanonicalForm subst ( const CanonicalForm f,
const CFList a,
const CFList b,
const CanonicalForm Rstar,
bool  isFunctionField 
)

Definition at line 120 of file facAlgFuncUtil.cc.

122 {
123  if (isFunctionField)
124  ASSERT (2*a.length() == b.length(), "wrong length of lists");
125  else
126  ASSERT (a.length() == b.length(), "lists of equal length expected");
127  CFListIterator j= b;
128  CanonicalForm result= f, tmp, powj;
129  CFListIterator i= a;
130  int length= a.length();
131  int count= 0;
132  for (; i.hasItem() && j.hasItem(); i++, j++, count++)
133  {
134  if (length - count == 2)
135  {
136  if (!isFunctionField)
137  {
138  result= result (b.getLast(), a.getLast().mvar());
139  result= result (j.getItem(), i.getItem().mvar());
140  break;
141  }
142  else
143  {
144  tmp= b.getLast();
145  j++;
146  j++;
147  powj= power (tmp, degree (result, a.getLast().mvar()));
148  result= evaluate (result, j.getItem(), tmp, powj, a.getLast().mvar());
149 
150  if (fdivides (powj, result, tmp))
151  result= tmp;
152 
153  result /= vcontent (result, Variable (a.getLast().level() + 1));
154  j--;
155  j--;
156  tmp= j.getItem();
157  j++;
158  powj= power (j.getItem(), degree (result, i.getItem().mvar()));
159  result= evaluate (result, tmp, j.getItem(), powj, i.getItem().mvar());
160 
161  if (fdivides (powj, result, tmp))
162  result= tmp;
163 
164  result /= vcontent (result, Variable (i.getItem().level() + 1));
165  break;
166  }
167  }
168  else
169  {
170  if (!isFunctionField)
171  result= result (j.getItem(), i.getItem().mvar());
172  else
173  {
174  tmp= j.getItem();
175  j++;
176  powj= power (j.getItem(), degree (result, i.getItem().mvar()));
177  result= evaluate (result, tmp, j.getItem(), powj, i.getItem().mvar());
178 
179  if (fdivides (powj, result, tmp))
180  result= tmp;
181 
182  result /= vcontent (result, Variable (i.getItem().level() + 1));
183  }
184  }
185  }
186  result= Prem (result, CFList (Rstar));
187  result /= vcontent (result, Variable (Rstar.level() + 1));
188  return result;
189 }
int status int void size_t count
Definition: si_signals.h:58
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
const poly a
Definition: syzextra.cc:212
CanonicalForm evaluate(const CanonicalForm &f, const CanonicalForm &g, const CanonicalForm &h, const CanonicalForm &powH)
f
Definition: cfModGcd.cc:4022
factory's class for variables
Definition: variable.h:32
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:230
factory's main class
Definition: canonicalform.h:72
int level() const
level() returns the level of CO.
int j
Definition: myNF.cc:70
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
T & getItem() const
Definition: ftmpl_list.cc:431
T getLast() const
Definition: ftmpl_list.cc:309
CanonicalForm Prem(const CanonicalForm &F, const CanonicalForm &G)
pseudo remainder of F by G with certain factors of LC (g) cancelled
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int degree(const CanonicalForm &f)
const poly b
Definition: syzextra.cc:213
return result
Definition: facAbsBiFact.cc:76
Varlist varsInAs ( const Varlist uord,
const CFList Astar 
)

Definition at line 66 of file facAlgFuncUtil.cc.

67 {
68  Varlist output;
69  CanonicalForm elem;
70  Variable x;
71 
72  for (VarlistIterator i= uord; i.hasItem(); i++)
73  {
74  x= i.getItem();
75  for (CFListIterator j= Astar; j.hasItem(); j++ )
76  {
77  elem= j.getItem();
78  if (degree (elem, x) > 0) // x actually occures in Astar
79  {
80  output.append (x);
81  break;
82  }
83  }
84  }
85  return output;
86 }
factory's class for variables
Definition: variable.h:32
factory's main class
Definition: canonicalform.h:72
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
Variable x
Definition: cfModGcd.cc:4023
void append(const T &)
Definition: ftmpl_list.cc:256
int degree(const CanonicalForm &f)