Functions
fac_sqrfree.cc File Reference
#include "config.h"
#include "cf_assert.h"
#include "cf_defs.h"
#include "canonicalform.h"
#include "cf_map.h"
#include "cf_algorithm.h"

Go to the source code of this file.

Functions

static int compareFactors (const CFFactor &f, const CFFactor &g)
 
CFFList sortCFFList (CFFList &F)
 
CFFList sqrFreeZ (const CanonicalForm &a)
 
CanonicalForm sqrfPart (const CanonicalForm &F)
 squarefree part of a poly More...
 

Function Documentation

◆ compareFactors()

static int compareFactors ( const CFFactor f,
const CFFactor g 
)
static

Definition at line 15 of file fac_sqrfree.cc.

16 {
17  return f.exp() > g.exp();
18 }
int exp() const
Definition: ftmpl_factor.h:31

◆ sortCFFList()

CFFList sortCFFList ( CFFList F)

Definition at line 21 of file fac_sqrfree.cc.

22 {
23  F.sort( compareFactors );
24 
25  int exp;
27  CFFListIterator I = F;
29 
30  // join elements with the same degree
31  while ( I.hasItem() ) {
32  f = I.getItem().factor();
33  exp = I.getItem().exp();
34  I++;
35  while ( I.hasItem() && I.getItem().exp() == exp ) {
36  f *= I.getItem().factor();
37  I++;
38  }
39  result.append( CFFactor( f, exp ) );
40  }
41 
42  return result;
43 }
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
factory's main class
Definition: canonicalform.h:77
T & getItem() const
Definition: ftmpl_list.cc:431
FILE * f
Definition: checklibs.c:9
static int compareFactors(const CFFactor &f, const CFFactor &g)
Definition: fac_sqrfree.cc:15
Factor< CanonicalForm > CFFactor
void append(const T &)
Definition: ftmpl_list.cc:256
return result
Definition: facAbsBiFact.cc:76
void sort(int(*)(const T &, const T &))
Definition: ftmpl_list.cc:339

◆ sqrfPart()

CanonicalForm sqrfPart ( const CanonicalForm F)

squarefree part of a poly

Parameters
[in]Fsome poly

Definition at line 111 of file fac_sqrfree.cc.

112 {
113  if (F.inCoeffDomain())
114  return F;
115  CFMap M;
116  CanonicalForm A= compress (F, M);
117  CanonicalForm w, v, b;
119  int i= 1;
120  for (; i <= A.level(); i++)
121  {
122  if (!deriv (A, Variable (i)).isZero())
123  break;
124  }
125 
126  w= gcd (A, deriv (A, Variable (i)));
127  b= A/w;
128  result= b;
129  if (degree (w) < 1)
130  return M (result);
131  i++;
132  for (; i <= A.level(); i++)
133  {
134  if (!deriv (w, Variable (i)).isZero())
135  {
136  b= w;
137  w= gcd (w, deriv (w, Variable (i)));
138  b /= w;
139  if (degree (b) < 1)
140  break;
141  CanonicalForm g= gcd (b, result);
142  if (degree (g) > 0)
143  result *= b/g;
144  if (degree (g) <= 0)
145  result *= b;
146  }
147  }
148  result= M (result);
149  return result;
150 }
CanonicalForm deriv(const CanonicalForm &f, const Variable &x)
factory&#39;s class for variables
Definition: factory.h:117
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
factory&#39;s main class
Definition: canonicalform.h:77
g
Definition: cfModGcd.cc:4031
CanonicalForm compress(const CanonicalForm &f, CFMap &m)
CanonicalForm compress ( const CanonicalForm & f, CFMap & m )
Definition: cf_map.cc:210
#define M
Definition: sirandom.c:25
CanonicalForm b
Definition: cfModGcd.cc:4044
#define A
Definition: sirandom.c:24
int i
Definition: cfEzgcd.cc:125
class CFMap
Definition: cf_map.h:84
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int gcd(int a, int b)
Definition: walkSupport.cc:836
const CanonicalForm & w
Definition: facAbsFact.cc:55
int level() const
level() returns the level of CO.
int degree(const CanonicalForm &f)
return result
Definition: facAbsBiFact.cc:76
bool inCoeffDomain() const

◆ sqrFreeZ()

CFFList sqrFreeZ ( const CanonicalForm a)

Definition at line 45 of file fac_sqrfree.cc.

46 {
47  if ( a.inCoeffDomain() )
48  return CFFactor( a, 1 );
49  CanonicalForm aa, LcA;
50  if (isOn (SW_RATIONAL))
51  {
52  LcA= bCommonDen (a);
53  aa= a*LcA;
54  }
55  else
56  {
57  LcA= icontent (a);
58  if (lc (a).sign() < 0)
59  LcA= -LcA;
60  aa= a/LcA;
61  }
62  CanonicalForm cont = content( aa );
63  aa /= cont;
64  CanonicalForm b = aa.deriv(), c = gcd( aa, b );
65  CanonicalForm y, z, w = aa / c;
66  int i = 1;
67  CFFList F;
68  Variable v = aa.mvar();
69  CanonicalForm lcinv;
70  while ( c.degree(v) != 0 )
71  {
72  y = gcd( w, c ); z = w / y;
73  if ( degree( z, v ) > 0 )
74  {
75  if (isOn (SW_RATIONAL))
76  {
77  lcinv= 1/Lc (z);
78  z *= lcinv;
79  z *= bCommonDen (z);
80  }
81  if (lc (z).sign() < 0)
82  z= -z;
83  F.append( CFFactor( z, i ) );
84  }
85  i++;
86  w = y; c = c / y;
87  }
88  if ( degree( w,v ) > 0 )
89  {
90  if (isOn (SW_RATIONAL))
91  {
92  lcinv= 1/Lc (w);
93  w *= lcinv;
94  w *= bCommonDen (w);
95  }
96  if (lc (w).sign() < 0)
97  w= -w;
98  F.append( CFFactor( w, i ) );
99  }
100  if ( ! cont.isOne() )
101  {
102  CFFList buf= sqrFreeZ (cont);
103  buf.removeFirst();
104  F = Union( F, buf );
105  }
106  F.insert (CFFactor (LcA, 1));
107  return F;
108 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
CanonicalForm icontent(const CanonicalForm &f)
CanonicalForm icontent ( const CanonicalForm & f )
Definition: cf_gcd.cc:71
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
CFFList sqrFreeZ(const CanonicalForm &a)
Definition: fac_sqrfree.cc:45
factory&#39;s class for variables
Definition: factory.h:117
factory&#39;s main class
Definition: canonicalform.h:77
void insert(const T &)
Definition: ftmpl_list.cc:193
CanonicalForm Lc(const CanonicalForm &f)
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.
void removeFirst()
Definition: ftmpl_list.cc:287
CanonicalForm content(const CanonicalForm &)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:175
CanonicalForm lc(const CanonicalForm &f)
template List< Variable > Union(const List< Variable > &, const List< Variable > &)
CanonicalForm b
Definition: cfModGcd.cc:4044
int status int void * buf
Definition: si_signals.h:59
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:29
bool isOn(int sw)
switches
int i
Definition: cfEzgcd.cc:125
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
Factor< CanonicalForm > CFFactor
int gcd(int a, int b)
Definition: walkSupport.cc:836
const CanonicalForm & w
Definition: facAbsFact.cc:55
void append(const T &)
Definition: ftmpl_list.cc:256
int degree(const CanonicalForm &f)
static int sign(int x)
Definition: ring.cc:3375
bool inCoeffDomain() const