Functions
cf_gcd.cc File Reference

gcd/content/lcm of polynomials More...

#include "config.h"
#include "timing.h"
#include "cf_assert.h"
#include "debug.h"
#include "cf_defs.h"
#include "canonicalform.h"
#include "cf_iter.h"
#include "cf_reval.h"
#include "cf_primes.h"
#include "cf_algorithm.h"
#include "cfEzgcd.h"
#include "cfGcdAlgExt.h"
#include "cfSubResGcd.h"
#include "cfModGcd.h"
#include <NTL/ZZX.h>
#include "NTLconvert.h"

Go to the source code of this file.

Functions

bool isPurePoly (const CanonicalForm &)
 
void out_cf (const char *s1, const CanonicalForm &f, const char *s2)
 cf_algorithm.cc - simple mathematical algorithms. More...
 
static CanonicalForm icontent (const CanonicalForm &f, const CanonicalForm &c)
 static CanonicalForm icontent ( const CanonicalForm & f, const CanonicalForm & c ) More...
 
CanonicalForm icontent (const CanonicalForm &f)
 CanonicalForm icontent ( const CanonicalForm & f ) More...
 
CanonicalForm gcd_poly (const CanonicalForm &f, const CanonicalForm &g)
 CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
static CanonicalForm cf_content (const CanonicalForm &f, const CanonicalForm &g)
 static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm content (const CanonicalForm &f)
 CanonicalForm content ( const CanonicalForm & f ) More...
 
CanonicalForm content (const CanonicalForm &f, const Variable &x)
 CanonicalForm content ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm vcontent (const CanonicalForm &f, const Variable &x)
 CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm pp (const CanonicalForm &f)
 CanonicalForm pp ( const CanonicalForm & f ) More...
 
CanonicalForm gcd (const CanonicalForm &f, const CanonicalForm &g)
 
CanonicalForm lcm (const CanonicalForm &f, const CanonicalForm &g)
 CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g ) More...
 

Detailed Description

gcd/content/lcm of polynomials

To compute the GCD different variants are chosen automatically

Definition in file cf_gcd.cc.

Function Documentation

§ cf_content()

static CanonicalForm cf_content ( const CanonicalForm f,
const CanonicalForm g 
)
static

static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g )

cf_content() - return gcd(g, content(f)).

content(f) is calculated with respect to f's main variable.

See also
gcd(), content(), content( CF, Variable ).

Definition at line 155 of file cf_gcd.cc.

156 {
157  if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
158  {
159  CFIterator i = f;
161  while ( i.hasTerms() && ! result.isOne() )
162  {
163  result = gcd( i.coeff(), result );
164  i++;
165  }
166  return result;
167  }
168  else
169  return abs( f );
170 }
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
bool inPolyDomain() const
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262
return result
Definition: facAbsBiFact.cc:76

§ content() [1/2]

CanonicalForm content ( const CanonicalForm f)

CanonicalForm content ( const CanonicalForm & f )

content() - return content(f) with respect to main variable.

Normalizes result.

Definition at line 180 of file cf_gcd.cc.

181 {
182  if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
183  {
184  CFIterator i = f;
185  CanonicalForm result = abs( i.coeff() );
186  i++;
187  while ( i.hasTerms() && ! result.isOne() )
188  {
189  result = gcd( i.coeff(), result );
190  i++;
191  }
192  return result;
193  }
194  else
195  return abs( f );
196 }
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
bool inPolyDomain() const
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262
return result
Definition: facAbsBiFact.cc:76

§ content() [2/2]

CanonicalForm content ( const CanonicalForm f,
const Variable x 
)

CanonicalForm content ( const CanonicalForm & f, const Variable & x )

content() - return content(f) with respect to x.

x should be a polynomial variable.

Definition at line 206 of file cf_gcd.cc.

207 {
208  if (f.inBaseDomain()) return f;
209  ASSERT( x.level() > 0, "cannot calculate content with respect to algebraic variable" );
210  Variable y = f.mvar();
211 
212  if ( y == x )
213  return cf_content( f, 0 );
214  else if ( y < x )
215  return f;
216  else
217  return swapvar( content( swapvar( f, y, x ), y ), y, x );
218 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: factory.h:115
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
bool inBaseDomain() const
int level() const
Definition: factory.h:132
static CanonicalForm cf_content(const CanonicalForm &f, const CanonicalForm &g)
static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g ) ...
Definition: cf_gcd.cc:155
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ gcd()

Definition at line 262 of file cf_gcd.cc.

263 {
264  bool b = f.isZero();
265  if ( b || g.isZero() )
266  {
267  if ( b )
268  return abs( g );
269  else
270  return abs( f );
271  }
272  if ( f.inPolyDomain() || g.inPolyDomain() )
273  {
274  if ( f.mvar() != g.mvar() )
275  {
276  if ( f.mvar() > g.mvar() )
277  return cf_content( f, g );
278  else
279  return cf_content( g, f );
280  }
281  if (isOn(SW_USE_QGCD))
282  {
283  Variable m;
284  if (
285  (getCharacteristic() == 0) &&
286  (hasFirstAlgVar(f,m) || hasFirstAlgVar(g,m))
287  )
288  {
289  bool on_rational = isOn(SW_RATIONAL);
290  CanonicalForm r=QGCD(f,g);
291  On(SW_RATIONAL);
292  CanonicalForm cdF = bCommonDen( r );
293  if (!on_rational) Off(SW_RATIONAL);
294  return cdF*r;
295  }
296  }
297 
298  if ( f.inExtension() && getReduce( f.mvar() ) )
299  return CanonicalForm(1);
300  else
301  {
302  if ( fdivides( f, g ) )
303  return abs( f );
304  else if ( fdivides( g, f ) )
305  return abs( g );
306  if ( !( getCharacteristic() == 0 && isOn( SW_RATIONAL ) ) )
307  {
308  CanonicalForm d;
309  d = gcd_poly( f, g );
310  return abs( d );
311  }
312  else
313  {
314  CanonicalForm cdF = bCommonDen( f );
315  CanonicalForm cdG = bCommonDen( g );
316  Off( SW_RATIONAL );
317  CanonicalForm l = lcm( cdF, cdG );
318  On( SW_RATIONAL );
319  CanonicalForm F = f * l, G = g * l;
320  Off( SW_RATIONAL );
321  l = gcd_poly( F, G );
322  On( SW_RATIONAL );
323  return abs( l );
324  }
325  }
326  }
327  if ( f.inBaseDomain() && g.inBaseDomain() )
328  return bgcd( f, g );
329  else
330  return 1;
331 }
void Off(int sw)
switches
factory&#39;s class for variables
Definition: factory.h:115
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm lcm(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:343
factory&#39;s main class
Definition: canonicalform.h:75
static TreeM * G
Definition: janet.cc:38
int getCharacteristic()
Definition: cf_char.cc:51
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
const ring r
Definition: syzextra.cc:208
bool inBaseDomain() const
bool inPolyDomain() const
CanonicalForm gcd_poly(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:94
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:665
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
static CanonicalForm cf_content(const CanonicalForm &f, const CanonicalForm &g)
static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g ) ...
Definition: cf_gcd.cc:155
int m
Definition: cfEzgcd.cc:119
bool isOn(int sw)
switches
void On(int sw)
switches
bool inExtension() const
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 )
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
CanonicalForm QGCD(const CanonicalForm &F, const CanonicalForm &G)
gcd over Q(a)
Definition: cfGcdAlgExt.cc:713
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
const poly b
Definition: syzextra.cc:213
int l
Definition: cfEzgcd.cc:94

§ gcd_poly()

CanonicalForm gcd_poly ( const CanonicalForm f,
const CanonicalForm g 
)

CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g )

gcd_poly() - calculate polynomial gcd.

This is the dispatcher for polynomial gcd calculation. Different gcd variants get called depending the input, characteristic, and on switches (cf_defs.h)

With the current settings from Singular (i.e. SW_USE_EZGCD= on, SW_USE_EZGCD_P= on, SW_USE_CHINREM_GCD= on, the EZ GCD variants are the default algorithms for multivariate polynomial GCD computations)

See also
gcd(), cf_defs.h

Definition at line 94 of file cf_gcd.cc.

95 {
96  CanonicalForm fc, gc, d1;
97  bool fc_isUnivariate=f.isUnivariate();
98  bool gc_isUnivariate=g.isUnivariate();
99  bool fc_and_gc_Univariate=fc_isUnivariate && gc_isUnivariate;
100  fc = f;
101  gc = g;
102  if ( getCharacteristic() != 0 )
103  {
104  #ifdef HAVE_NTL
105  if ((!fc_and_gc_Univariate) && (isOn( SW_USE_EZGCD_P )))
106  {
107  fc= EZGCD_P (fc, gc);
108  }
109  else if (isOn(SW_USE_FF_MOD_GCD) && !fc_and_gc_Univariate)
110  {
111  Variable a;
112  if (hasFirstAlgVar (fc, a) || hasFirstAlgVar (gc, a))
113  fc=modGCDFq (fc, gc, a);
115  fc=modGCDGF (fc, gc);
116  else
117  fc=modGCDFp (fc, gc);
118  }
119  else
120  #endif
121  fc = subResGCD_p( fc, gc );
122  }
123  else if (!fc_and_gc_Univariate)
124  {
125  if ( isOn( SW_USE_EZGCD ) )
126  fc= ezgcd (fc, gc);
127 #ifdef HAVE_NTL
128  else if (isOn(SW_USE_CHINREM_GCD))
129  fc = modGCDZ( fc, gc);
130 #endif
131  else
132  {
133  fc = subResGCD_0( fc, gc );
134  }
135  }
136  else
137  {
138  fc = subResGCD_0( fc, gc );
139  }
140  if ( d1.degree() > 0 )
141  fc *= d1;
142  return fc;
143 }
static CanonicalForm ezgcd(const CanonicalForm &FF, const CanonicalForm &GG, REvaluation &b, bool internal)
real implementation of EZGCD over Z
Definition: cfEzgcd.cc:438
const poly a
Definition: syzextra.cc:212
static const int SW_USE_FF_MOD_GCD
set to 1 to use modular GCD over F_q
Definition: cf_defs.h:42
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: factory.h:115
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
CanonicalForm modGCDGF(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, CFList &l, bool &topLevel)
GCD of F and G over GF, based on Alg. 7.2. as described in "Algorithms for Computer Algebra" by Gedde...
Definition: cfModGcd.cc:860
int getCharacteristic()
Definition: cf_char.cc:51
CanonicalForm subResGCD_p(const CanonicalForm &f, const CanonicalForm &g)
subresultant GCD over finite fields. In case things become too dense we switch to a modular algorithm...
Definition: cfSubResGcd.cc:12
CanonicalForm modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
Definition: cfModGcd.cc:1206
bool isUnivariate() const
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:665
bool isOn(int sw)
switches
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:38
CanonicalForm modGCDFq(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, Variable &alpha, CFList &l, bool &topLevel)
GCD of F and G over , l and topLevel are only used internally, output is monic based on Alg...
Definition: cfModGcd.cc:467
CanonicalForm EZGCD_P(const CanonicalForm &FF, const CanonicalForm &GG)
Extended Zassenhaus GCD for finite fields. In case things become too dense we switch to a modular alg...
Definition: cfEzgcd.cc:802
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
static int gettype()
Definition: cf_factory.h:27
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:32
#define GaloisFieldDomain
Definition: cf_defs.h:22
CanonicalForm subResGCD_0(const CanonicalForm &f, const CanonicalForm &g)
subresultant GCD over Z.
Definition: cfSubResGcd.cc:165

§ icontent() [1/2]

static CanonicalForm icontent ( const CanonicalForm f,
const CanonicalForm c 
)
static

static CanonicalForm icontent ( const CanonicalForm & f, const CanonicalForm & c )

icontent() - return gcd of c and all coefficients of f which are in a coefficient domain.

See also
icontent().

Definition at line 46 of file cf_gcd.cc.

47 {
48  if ( f.inBaseDomain() )
49  {
50  if (c.isZero()) return abs(f);
51  return bgcd( f, c );
52  }
53  //else if ( f.inCoeffDomain() )
54  // return gcd(f,c);
55  else
56  {
57  CanonicalForm g = c;
58  for ( CFIterator i = f; i.hasTerms() && ! g.isOne(); i++ )
59  g = icontent( i.coeff(), g );
60  return g;
61  }
62 }
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
static CanonicalForm icontent(const CanonicalForm &f, const CanonicalForm &c)
static CanonicalForm icontent ( const CanonicalForm & f, const CanonicalForm & c ) ...
Definition: cf_gcd.cc:46
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
bool inBaseDomain() const
int i
Definition: cfEzgcd.cc:123
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44

§ icontent() [2/2]

CanonicalForm icontent ( const CanonicalForm f)

CanonicalForm icontent ( const CanonicalForm & f )

icontent() - return gcd over all coefficients of f which are in a coefficient domain.

Definition at line 71 of file cf_gcd.cc.

72 {
73  return icontent( f, 0 );
74 }
static CanonicalForm icontent(const CanonicalForm &f, const CanonicalForm &c)
static CanonicalForm icontent ( const CanonicalForm & f, const CanonicalForm & c ) ...
Definition: cf_gcd.cc:46

§ isPurePoly()

bool isPurePoly ( const CanonicalForm )

Definition at line 229 of file cf_factor.cc.

230 {
231  if (f.level()<=0) return false;
232  for (CFIterator i=f;i.hasTerms();i++)
233  {
234  if (!(i.coeff().inBaseDomain())) return false;
235  }
236  return true;
237 }
f
Definition: cfModGcd.cc:4022
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44

§ lcm()

CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g )

lcm() - return least common multiple of f and g.

The lcm is calculated using the formula lcm(f, g) = f * g / gcd(f, g).

Returns zero if one of f or g equals zero.

Definition at line 343 of file cf_gcd.cc.

344 {
345  if ( f.isZero() || g.isZero() )
346  return 0;
347  else
348  return ( f / gcd( f, g ) ) * g;
349 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262

§ out_cf()

void out_cf ( const char *  s1,
const CanonicalForm f,
const char *  s2 
)

cf_algorithm.cc - simple mathematical algorithms.

Hierarchy: mathematical algorithms on canonical forms

Developers note:

A "mathematical" algorithm is an algorithm which calculates some mathematical function in contrast to a "structural" algorithm which gives structural information on polynomials.

Compare these functions to the functions in `cf_ops.cc', which are structural algorithms.

Definition at line 90 of file cf_factor.cc.

91 {
92  printf("%s",s1);
93  if (f.isZero()) printf("+0");
94  //else if (! f.inCoeffDomain() )
95  else if (! f.inBaseDomain() )
96  {
97  int l = f.level();
98  for ( CFIterator i = f; i.hasTerms(); i++ )
99  {
100  int e=i.exp();
101  if (i.coeff().isOne())
102  {
103  printf("+");
104  if (e==0) printf("1");
105  else
106  {
107  printf("v(%d)",l);
108  if (e!=1) printf("^%d",e);
109  }
110  }
111  else
112  {
113  out_cf("+(",i.coeff(),")");
114  if (e!=0)
115  {
116  printf("*v(%d)",l);
117  if (e!=1) printf("^%d",e);
118  }
119  }
120  }
121  }
122  else
123  {
124  if ( f.isImm() )
125  {
127  {
128  long a= imm2int (f.getval());
129  if ( a == gf_q )
130  printf ("+%ld", a);
131  else if ( a == 0L )
132  printf ("+1");
133  else if ( a == 1L )
134  printf ("+%c",gf_name);
135  else
136  {
137  printf ("+%c",gf_name);
138  printf ("^%ld",a);
139  }
140  }
141  else
142  printf("+%ld",f.intval());
143  }
144  else
145  {
146  #ifdef NOSTREAMIO
147  if (f.inZ())
148  {
149  mpz_t m;
150  gmp_numerator(f,m);
151  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
152  str = mpz_get_str( str, 10, m );
153  printf("%s",str);
154  delete[] str;
155  mpz_clear(m);
156  }
157  else if (f.inQ())
158  {
159  mpz_t m;
160  gmp_numerator(f,m);
161  char * str = new char[mpz_sizeinbase( m, 10 ) + 2];
162  str = mpz_get_str( str, 10, m );
163  printf("%s/",str);
164  delete[] str;
165  mpz_clear(m);
166  gmp_denominator(f,m);
167  str = new char[mpz_sizeinbase( m, 10 ) + 2];
168  str = mpz_get_str( str, 10, m );
169  printf("%s",str);
170  delete[] str;
171  mpz_clear(m);
172  }
173  #else
174  std::cout << f;
175  #endif
176  }
177  //if (f.inZ()) printf("(Z)");
178  //else if (f.inQ()) printf("(Q)");
179  //else if (f.inFF()) printf("(FF)");
180  //else if (f.inPP()) printf("(PP)");
181  //else if (f.inGF()) printf("(PP)");
182  //else
183  if (f.inExtension()) printf("E(%d)",f.level());
184  }
185  printf("%s",s2);
186 }
long intval() const
conversion functions
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
bool isImm() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
char gf_name
Definition: gfops.cc:52
int gf_q
Definition: gfops.cc:47
bool inBaseDomain() const
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
void out_cf(const char *s1, const CanonicalForm &f, const char *s2)
cf_algorithm.cc - simple mathematical algorithms.
Definition: cf_factor.cc:90
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
static int gettype()
Definition: cf_factory.h:27
bool inQ() const
bool inZ() const
predicates
#define GaloisFieldDomain
Definition: cf_defs.h:22
int level() const
level() returns the level of CO.
InternalCF * getval() const
int l
Definition: cfEzgcd.cc:94
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40

§ pp()

CanonicalForm pp ( const CanonicalForm & f )

pp() - return primitive part of f.

Returns zero if f equals zero, otherwise f / content(f).

Definition at line 253 of file cf_gcd.cc.

254 {
255  if ( f.isZero() )
256  return f;
257  else
258  return f / content( f );
259 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180

§ vcontent()

CanonicalForm vcontent ( const CanonicalForm f,
const Variable x 
)

CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )

vcontent() - return content of f with repect to variables >= x.

The content is recursively calculated over all coefficients in f having level less than x. x should be a polynomial variable.

Definition at line 230 of file cf_gcd.cc.

231 {
232  ASSERT( x.level() > 0, "cannot calculate vcontent with respect to algebraic variable" );
233 
234  if ( f.mvar() <= x )
235  return content( f, x );
236  else {
237  CFIterator i;
238  CanonicalForm d = 0;
239  for ( i = f; i.hasTerms() && ! d.isOne(); i++ )
240  d = gcd( d, vcontent( i.coeff(), x ) );
241  return d;
242  }
243 }
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:230
int level() const
Definition: factory.h:132
int i
Definition: cfEzgcd.cc:123
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
Variable x
Definition: cfModGcd.cc:4023
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180
#define ASSERT(expression, message)
Definition: cf_assert.h:99
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262