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 150 of file cf_gcd.cc.

151 {
152  if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
153  {
154  CFIterator i = f;
156  while ( i.hasTerms() && ! result.isOne() )
157  {
158  result = gcd( i.coeff(), result );
159  i++;
160  }
161  return result;
162  }
163  else
164  return abs( f );
165 }
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:77
g
Definition: cfModGcd.cc:4031
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
bool inPolyDomain() const
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
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:257
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 175 of file cf_gcd.cc.

176 {
177  if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
178  {
179  CFIterator i = f;
180  CanonicalForm result = abs( i.coeff() );
181  i++;
182  while ( i.hasTerms() && ! result.isOne() )
183  {
184  result = gcd( i.coeff(), result );
185  i++;
186  }
187  return result;
188  }
189  else
190  return abs( f );
191 }
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:77
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
bool inPolyDomain() const
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
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:257
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 201 of file cf_gcd.cc.

202 {
203  if (f.inBaseDomain()) return f;
204  ASSERT( x.level() > 0, "cannot calculate content with respect to algebraic variable" );
205  Variable y = f.mvar();
206 
207  if ( y == x )
208  return cf_content( f, 0 );
209  else if ( y < x )
210  return f;
211  else
212  return swapvar( content( swapvar( f, y, x ), y ), y, x );
213 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
factory&#39;s class for variables
Definition: factory.h:117
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:134
static CanonicalForm cf_content(const CanonicalForm &f, const CanonicalForm &g)
static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g ) ...
Definition: cf_gcd.cc:150
FILE * f
Definition: checklibs.c:9
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:175
#define ASSERT(expression, message)
Definition: cf_assert.h:99

◆ gcd()

Definition at line 257 of file cf_gcd.cc.

258 {
259  bool b = f.isZero();
260  if ( b || g.isZero() )
261  {
262  if ( b )
263  return abs( g );
264  else
265  return abs( f );
266  }
267  if ( f.inPolyDomain() || g.inPolyDomain() )
268  {
269  if ( f.mvar() != g.mvar() )
270  {
271  if ( f.mvar() > g.mvar() )
272  return cf_content( f, g );
273  else
274  return cf_content( g, f );
275  }
276  if (isOn(SW_USE_QGCD))
277  {
278  Variable m;
279  if (
280  (getCharacteristic() == 0) &&
281  (hasFirstAlgVar(f,m) || hasFirstAlgVar(g,m))
282  )
283  {
284  bool on_rational = isOn(SW_RATIONAL);
285  CanonicalForm r=QGCD(f,g);
286  On(SW_RATIONAL);
287  CanonicalForm cdF = bCommonDen( r );
288  if (!on_rational) Off(SW_RATIONAL);
289  return cdF*r;
290  }
291  }
292 
293  if ( f.inExtension() && getReduce( f.mvar() ) )
294  return CanonicalForm(1);
295  else
296  {
297  if ( fdivides( f, g ) )
298  return abs( f );
299  else if ( fdivides( g, f ) )
300  return abs( g );
301  if ( !( getCharacteristic() == 0 && isOn( SW_RATIONAL ) ) )
302  {
303  CanonicalForm d;
304  d = gcd_poly( f, g );
305  return abs( d );
306  }
307  else
308  {
309  CanonicalForm cdF = bCommonDen( f );
310  CanonicalForm cdG = bCommonDen( g );
311  Off( SW_RATIONAL );
312  CanonicalForm l = lcm( cdF, cdG );
313  On( SW_RATIONAL );
314  CanonicalForm F = f * l, G = g * l;
315  Off( SW_RATIONAL );
316  l = gcd_poly( F, G );
317  On( SW_RATIONAL );
318  return abs( l );
319  }
320  }
321  }
322  if ( f.inBaseDomain() && g.inBaseDomain() )
323  return bgcd( f, g );
324  else
325  return 1;
326 }
void Off(int sw)
switches
factory&#39;s class for variables
Definition: factory.h:117
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:338
factory&#39;s main class
Definition: canonicalform.h:77
int getCharacteristic()
Definition: cf_char.cc:51
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
CanonicalForm b
Definition: cfModGcd.cc:4044
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:91
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:29
static CanonicalForm cf_content(const CanonicalForm &f, const CanonicalForm &g)
static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g ) ...
Definition: cf_gcd.cc:150
int m
Definition: cfEzgcd.cc:121
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:715
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:41
STATIC_VAR TreeM * G
Definition: janet.cc:31
int l
Definition: cfEzgcd.cc:93

◆ 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 91 of file cf_gcd.cc.

92 {
93  CanonicalForm fc, gc;
94  bool fc_isUnivariate=f.isUnivariate();
95  bool gc_isUnivariate=g.isUnivariate();
96  bool fc_and_gc_Univariate=fc_isUnivariate && gc_isUnivariate;
97  fc = f;
98  gc = g;
99  if ( getCharacteristic() != 0 )
100  {
101  #ifdef HAVE_NTL
102  if ((!fc_and_gc_Univariate) && (isOn( SW_USE_EZGCD_P )))
103  {
104  fc= EZGCD_P (fc, gc);
105  }
106  else if (isOn(SW_USE_FF_MOD_GCD) && !fc_and_gc_Univariate)
107  {
108  Variable a;
109  if (hasFirstAlgVar (fc, a) || hasFirstAlgVar (gc, a))
110  fc=modGCDFq (fc, gc, a);
112  fc=modGCDGF (fc, gc);
113  else
114  fc=modGCDFp (fc, gc);
115  }
116  else
117  #endif
118  fc = subResGCD_p( fc, gc );
119  }
120  else if (!fc_and_gc_Univariate)
121  {
122  if ( isOn( SW_USE_EZGCD ) )
123  fc= ezgcd (fc, gc);
124 #ifdef HAVE_NTL
125  else if (isOn(SW_USE_CHINREM_GCD))
126  fc = modGCDZ( fc, gc);
127 #endif
128  else
129  {
130  fc = subResGCD_0( fc, gc );
131  }
132  }
133  else
134  {
135  fc = subResGCD_0( fc, gc );
136  }
137  return fc;
138 }
static CanonicalForm ezgcd(const CanonicalForm &FF, const CanonicalForm &GG, REvaluation &b, bool internal)
real implementation of EZGCD over Z
Definition: cfEzgcd.cc:481
static const int SW_USE_FF_MOD_GCD
set to 1 to use modular GCD over F_q
Definition: cf_defs.h:43
factory&#39;s class for variables
Definition: factory.h:117
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:35
factory&#39;s main class
Definition: canonicalform.h:77
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
FILE * f
Definition: checklibs.c:9
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:39
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:862
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
static int gettype()
Definition: cf_factory.h:28
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:33
#define GaloisFieldDomain
Definition: cf_defs.h:23
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:77
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:436
bool inBaseDomain() const
int i
Definition: cfEzgcd.cc:125
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 }
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
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 338 of file cf_gcd.cc.

339 {
340  if ( f.isZero() || g.isZero() )
341  return 0;
342  else
343  return ( f / gcd( f, g ) ) * g;
344 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:257

◆ 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  puts(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  puts(str);putchar('/');
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  puts(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
VAR char gf_name
Definition: gfops.cc:52
bool isImm() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
bool inBaseDomain() const
int m
Definition: cfEzgcd.cc:121
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
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
static long imm2int(const InternalCF *const imm)
Definition: imm.h:70
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
VAR int gf_q
Definition: gfops.cc:47
static int gettype()
Definition: cf_factory.h:28
bool inQ() const
bool inZ() const
predicates
#define GaloisFieldDomain
Definition: cf_defs.h:23
int level() const
level() returns the level of CO.
InternalCF * getval() const
int l
Definition: cfEzgcd.cc:93
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 248 of file cf_gcd.cc.

249 {
250  if ( f.isZero() )
251  return f;
252  else
253  return f / content( f );
254 }
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:175

◆ 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 225 of file cf_gcd.cc.

226 {
227  ASSERT( x.level() > 0, "cannot calculate vcontent with respect to algebraic variable" );
228 
229  if ( f.mvar() <= x )
230  return content( f, x );
231  else {
232  CFIterator i;
233  CanonicalForm d = 0;
234  for ( i = f; i.hasTerms() && ! d.isOne(); i++ )
235  d = gcd( d, vcontent( i.coeff(), x ) );
236  return d;
237  }
238 }
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:77
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:225
int level() const
Definition: factory.h:134
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.
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:175
#define ASSERT(expression, message)
Definition: cf_assert.h:99
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:257