My Project  debian-1:4.1.1-p2+ds-4build4
Data Structures | Macros | Typedefs | Functions
canonicalform.h File Reference

Header for factory's main class CanonicalForm. More...

#include <iostream>
#include <stdint.h>
#include "cf_defs.h"
#include "variable.h"
#include "factory/cf_gmp.h"
#include "factory/templates/ftmpl_list.h"
#include "factory/templates/ftmpl_array.h"
#include "factory/templates/ftmpl_afactor.h"
#include "factory/templates/ftmpl_factor.h"
#include "factory/templates/ftmpl_matrix.h"
#include "omalloc/omallocClass.h"

Go to the source code of this file.

Data Structures

class  CanonicalForm
 factory's main class More...
 

Macros

#define OSTREAM   std::ostream
 
#define ISTREAM   std::istream
 
#define CF_INLINE
 
#define CF_NO_INLINE
 
#define CF_INLINE
 

Typedefs

typedef AFactor< CanonicalFormCFAFactor
 
typedef List< CFAFactorCFAFList
 
typedef ListIterator< CFAFactorCFAFListIterator
 
typedef Factor< CanonicalFormCFFactor
 
typedef List< CFFactorCFFList
 
typedef ListIterator< CFFactorCFFListIterator
 
typedef List< CanonicalFormCFList
 
typedef ListIterator< CanonicalFormCFListIterator
 
typedef Array< CanonicalFormCFArray
 
typedef Matrix< CanonicalFormCFMatrix
 
typedef List< CFListListCFList
 
typedef ListIterator< CFListListCFListIterator
 
typedef List< int > IntList
 
typedef ListIterator< int > IntListIterator
 
typedef List< VariableVarlist
 
typedef ListIterator< VariableVarlistIterator
 
typedef Array< int > Intarray
 

Functions

int is_imm (const InternalCF *const ptr)
 
CF_INLINE CanonicalForm operator+ (const CanonicalForm &, const CanonicalForm &)
 CF_INLINE CanonicalForm operator +, -, *, /, % ( const CanonicalForm & lhs, const CanonicalForm & rhs ) More...
 
CF_NO_INLINE CanonicalForm operator- (const CanonicalForm &, const CanonicalForm &)
 
CF_INLINE CanonicalForm operator* (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm operator/ (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm operator% (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm div (const CanonicalForm &, const CanonicalForm &)
 CF_INLINE CanonicalForm div, mod ( const CanonicalForm & lhs, const CanonicalForm & rhs ) More...
 
CF_NO_INLINE CanonicalForm mod (const CanonicalForm &, const CanonicalForm &)
 
CanonicalForm blcm (const CanonicalForm &f, const CanonicalForm &g)
 
CanonicalForm power (const CanonicalForm &f, int n)
 exponentiation More...
 
CanonicalForm power (const Variable &v, int n)
 exponentiation More...
 
CanonicalForm gcd (const CanonicalForm &, const CanonicalForm &)
 
CanonicalForm gcd_poly (const CanonicalForm &f, const CanonicalForm &g)
 CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm lcm (const CanonicalForm &, const CanonicalForm &)
 CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm pp (const CanonicalForm &)
 CanonicalForm pp ( const CanonicalForm & f ) More...
 
CanonicalForm content (const CanonicalForm &)
 CanonicalForm content ( const CanonicalForm & f ) More...
 
CanonicalForm content (const CanonicalForm &, const Variable &)
 CanonicalForm content ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm icontent (const CanonicalForm &f)
 CanonicalForm icontent ( const CanonicalForm & f ) More...
 
CanonicalForm vcontent (const CanonicalForm &f, const Variable &x)
 CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm swapvar (const CanonicalForm &, const Variable &, const Variable &)
 swapvar() - swap variables x1 and x2 in f. More...
 
CanonicalForm replacevar (const CanonicalForm &, const Variable &, const Variable &)
 CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 ) More...
 
int getNumVars (const CanonicalForm &f)
 int getNumVars ( const CanonicalForm & f ) More...
 
CanonicalForm getVars (const CanonicalForm &f)
 CanonicalForm getVars ( const CanonicalForm & f ) More...
 
CanonicalForm apply (const CanonicalForm &f, void(*mf)(CanonicalForm &, int &))
 CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) ) More...
 
CanonicalForm mapdomain (const CanonicalForm &f, CanonicalForm(*mf)(const CanonicalForm &))
 CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ) More...
 
int * degrees (const CanonicalForm &f, int *degs=0)
 int * degrees ( const CanonicalForm & f, int * degs ) More...
 
int totaldegree (const CanonicalForm &f)
 int totaldegree ( const CanonicalForm & f ) More...
 
int totaldegree (const CanonicalForm &f, const Variable &v1, const Variable &v2)
 int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 ) More...
 
int size (const CanonicalForm &f, const Variable &v)
 int size ( const CanonicalForm & f, const Variable & v ) More...
 
int size (const CanonicalForm &f)
 int size ( const CanonicalForm & f ) More...
 
CanonicalForm reduce (const CanonicalForm &f, const CanonicalForm &M)
 polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of f are reduced modulo M More...
 
bool hasFirstAlgVar (const CanonicalForm &f, Variable &a)
 check if poly f contains an algebraic variable a More...
 
CanonicalForm leftShift (const CanonicalForm &F, int n)
 left shift the main variable of F by n More...
 
CanonicalForm lc (const CanonicalForm &f)
 
CanonicalForm Lc (const CanonicalForm &f)
 
CanonicalForm LC (const CanonicalForm &f)
 
CanonicalForm LC (const CanonicalForm &f, const Variable &v)
 
int degree (const CanonicalForm &f)
 
int degree (const CanonicalForm &f, const Variable &v)
 
int taildegree (const CanonicalForm &f)
 
CanonicalForm tailcoeff (const CanonicalForm &f)
 
CanonicalForm tailcoeff (const CanonicalForm &f, const Variable &v)
 
int level (const CanonicalForm &f)
 
Variable mvar (const CanonicalForm &f)
 
CanonicalForm num (const CanonicalForm &f)
 
CanonicalForm den (const CanonicalForm &f)
 
int sign (const CanonicalForm &a)
 
CanonicalForm deriv (const CanonicalForm &f, const Variable &x)
 
CanonicalForm sqrt (const CanonicalForm &a)
 
int ilog2 (const CanonicalForm &a)
 
CanonicalForm mapinto (const CanonicalForm &f)
 
CanonicalForm head (const CanonicalForm &f)
 
int headdegree (const CanonicalForm &f)
 
void setCharacteristic (int c)
 
void setCharacteristic (int c, int n)
 
void setCharacteristic (int c, int n, char name)
 
int getCharacteristic ()
 
int getGFDegree ()
 
CanonicalForm getGFGenerator ()
 
void On (int)
 switches More...
 
void Off (int)
 switches More...
 
bool isOn (int)
 switches More...
 

Detailed Description

Header for factory's main class CanonicalForm.

Definition in file canonicalform.h.

Macro Definition Documentation

◆ CF_INLINE [1/2]

#define CF_INLINE

Definition at line 55 of file canonicalform.h.

◆ CF_INLINE [2/2]

#define CF_INLINE

Definition at line 55 of file canonicalform.h.

◆ CF_NO_INLINE

#define CF_NO_INLINE

Definition at line 46 of file canonicalform.h.

◆ ISTREAM

#define ISTREAM   std::istream

Definition at line 17 of file canonicalform.h.

◆ OSTREAM

#define OSTREAM   std::ostream

Definition at line 16 of file canonicalform.h.

Typedef Documentation

◆ CFAFactor

Definition at line 382 of file canonicalform.h.

◆ CFAFList

Definition at line 383 of file canonicalform.h.

◆ CFAFListIterator

Definition at line 384 of file canonicalform.h.

◆ CFArray

Definition at line 390 of file canonicalform.h.

◆ CFFactor

Definition at line 385 of file canonicalform.h.

◆ CFFList

typedef List<CFFactor> CFFList

Definition at line 386 of file canonicalform.h.

◆ CFFListIterator

Definition at line 387 of file canonicalform.h.

◆ CFList

Definition at line 388 of file canonicalform.h.

◆ CFListIterator

Definition at line 389 of file canonicalform.h.

◆ CFMatrix

Definition at line 391 of file canonicalform.h.

◆ Intarray

typedef Array<int> Intarray

Definition at line 398 of file canonicalform.h.

◆ IntList

typedef List<int> IntList

Definition at line 394 of file canonicalform.h.

◆ IntListIterator

Definition at line 395 of file canonicalform.h.

◆ ListCFList

Definition at line 392 of file canonicalform.h.

◆ ListCFListIterator

Definition at line 393 of file canonicalform.h.

◆ Varlist

typedef List<Variable> Varlist

Definition at line 396 of file canonicalform.h.

◆ VarlistIterator

Definition at line 397 of file canonicalform.h.

Function Documentation

◆ apply()

CanonicalForm apply ( const CanonicalForm f,
void(*)(CanonicalForm &, int &)  mf 
)

CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) )

apply() - apply mf to terms of f.

Calls mf( f[i], i ) for each term f[i]*x^i of f and builds a new term from the result. If f is in a coefficient domain, mf( f, i ) should result in an i == 0, since otherwise it is not clear which variable to use for the resulting term.

An example:

void
diff( CanonicalForm & f, int & i )
{
f = f * i;
if ( i > 0 ) i--;
}
int i
Definition: cfEzgcd.cc:125
FILE * f
Definition: checklibs.c:9
factory's main class
Definition: canonicalform.h:83
static gmp_float * diff
Definition: mpr_complex.cc:46

Then apply( f, diff ) is differentation of f with respect to the main variable of f.

Definition at line 402 of file cf_ops.cc.

403 {
404  if ( f.inCoeffDomain() )
405  {
406  int exp = 0;
408  mf( result, exp );
409  ASSERT( exp == 0, "illegal result, do not know what variable to use" );
410  return result;
411  }
412  else
413  {
414  CanonicalForm result, coeff;
415  CFIterator i;
416  int exp;
417  Variable x = f.mvar();
418  for ( i = f; i.hasTerms(); i++ )
419  {
420  coeff = i.coeff();
421  exp = i.exp();
422  mf( coeff, exp );
423  if ( ! coeff.isZero() )
424  result += power( x, exp ) * coeff;
425  }
426  return result;
427  }
428 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable x
Definition: cfModGcd.cc:4023
#define ASSERT(expression, message)
Definition: cf_assert.h:99
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
factory's class for variables
Definition: factory.h:118
return result
Definition: facAbsBiFact.cc:76
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358

◆ blcm()

Definition at line 1757 of file canonicalform.cc.

1758 {
1759  if ( f.isZero() || g.isZero() )
1760  return CanonicalForm( 0L );
1761 /*
1762  else if (f.isOne())
1763  return g;
1764  else if (g.isOne())
1765  return f;
1766 */
1767  else
1768  return (f / bgcd( f, g )) * g;
1769 }
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
g
Definition: cfModGcd.cc:4031

◆ 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 }
Rational abs(const Rational &a)
Definition: GMPrat.cc:439
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262
bool getReduce(const Variable &alpha)
Definition: variable.cc:232

◆ 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 }
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
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
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180
int level() const
Definition: factory.h:134
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57

◆ degree() [1/2]

int degree ( const CanonicalForm f)
inline

Definition at line 309 of file canonicalform.h.

309 { return f.degree(); }

◆ degree() [2/2]

int degree ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 312 of file canonicalform.h.

312 { return f.degree( v ); }
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37

◆ degrees()

int* degrees ( const CanonicalForm f,
int *  degs 
)

int * degrees ( const CanonicalForm & f, int * degs )

degress() - return the degrees of all polynomial variables in f.

Returns 0 if f is in a coefficient domain, the degrees of f in all its polynomial variables in an array of int otherwise:

degrees( f, 0 )[i] = degree( f, Variable(i) )

If degs is not the zero pointer the degrees are stored in this array. In this case degs should be larger than the level of f. If degs is the zero pointer, an array of sufficient size is allocated automatically.

Definition at line 493 of file cf_ops.cc.

494 {
495  if ( f.inCoeffDomain() )
496  {
497  if (degs != 0)
498  return degs;
499  else
500  return 0;
501  }
502  else
503  {
504  int level = f.level();
505  if ( degs == NULL )
506  degs = NEW_ARRAY(int,level+1);
507  for ( int i = level; i >= 0; i-- )
508  degs[i] = 0;
509  degreesRec( f, degs );
510  return degs;
511  }
512 }
int level(const CanonicalForm &f)
#define NEW_ARRAY(T, N)
Definition: cf_defs.h:48
static void degreesRec(const CanonicalForm &f, int *degs)
static void degreesRec ( const CanonicalForm & f, int * degs )
Definition: cf_ops.cc:463
#define NULL
Definition: omList.c:10

◆ den()

CanonicalForm den ( const CanonicalForm f)
inline

Definition at line 333 of file canonicalform.h.

333 { return f.den(); }

◆ deriv()

CanonicalForm deriv ( const CanonicalForm f,
const Variable x 
)
inline

Definition at line 339 of file canonicalform.h.

339 { return f.deriv( x ); }

◆ div()

CF_INLINE CanonicalForm div, mod ( const CanonicalForm & lhs, const CanonicalForm & rhs )

See also
mod(), operator/(), CanonicalForm::operator /=()

Definition at line 553 of file cf_inline.cc.

554 {
555  CanonicalForm result( lhs );
556  result.div( rhs );
557  return result;
558 }

◆ 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) &&
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 }
bool isOn(int sw)
switches
void On(int sw)
switches
void Off(int sw)
switches
int getCharacteristic()
Definition: cf_char.cc:51
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:665
int l
Definition: cfEzgcd.cc:93
int m
Definition: cfEzgcd.cc:121
CanonicalForm QGCD(const CanonicalForm &F, const CanonicalForm &G)
gcd over Q(a)
Definition: cfGcdAlgExt.cc:715
CanonicalForm b
Definition: cfModGcd.cc:4044
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CanonicalForm gcd_poly(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:94
CanonicalForm lcm(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:343
static TreeM * G
Definition: janet.cc:32

◆ 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 }
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:815
static CanonicalForm ezgcd(const CanonicalForm &FF, const CanonicalForm &GG, REvaluation &b, bool internal)
real implementation of EZGCD over Z
Definition: cfEzgcd.cc:441
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 modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
Definition: cfModGcd.cc:1206
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
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
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 subResGCD_0(const CanonicalForm &f, const CanonicalForm &g)
subresultant GCD over Z.
Definition: cfSubResGcd.cc:165
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:38
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
static const int SW_USE_FF_MOD_GCD
set to 1 to use modular GCD over F_q
Definition: cf_defs.h:42
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
static int gettype()
Definition: cf_factory.h:28
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.

◆ getCharacteristic()

int getCharacteristic ( )

Definition at line 51 of file cf_char.cc.

52 {
53  return theCharacteristic;
54 }
static int theCharacteristic
Definition: cf_char.cc:20

◆ getGFDegree()

int getGFDegree ( )

Definition at line 56 of file cf_char.cc.

57 {
58  //ASSERT( theDegree > 0, "not in GF(q)" );
59  return theDegree;
60 }
static int theDegree
Definition: cf_char.cc:21

◆ getGFGenerator()

CanonicalForm getGFGenerator ( )

Definition at line 62 of file cf_char.cc.

63 {
64  ASSERT( theDegree > 1, "not in GF(q)" );
65  return int2imm_gf( 1 );
66 }
InternalCF * int2imm_gf(long i)
Definition: imm.h:106

◆ getNumVars()

int getNumVars ( const CanonicalForm f)

int getNumVars ( const CanonicalForm & f )

getNumVars() - get number of polynomial variables in f.

Definition at line 314 of file cf_ops.cc.

315 {
316  int n;
317  if ( f.inCoeffDomain() )
318  return 0;
319  else if ( (n = f.level()) == 1 )
320  return 1;
321  else
322  {
323  int * vars = NEW_ARRAY(int, n+1);
324  int i;
325  for ( i = n-1; i >=0; i-- ) vars[i] = 0;
326 
327  // look for variables
328  for ( CFIterator I = f; I.hasTerms(); ++I )
329  fillVarsRec( I.coeff(), vars );
330 
331  // count them
332  int m = 0;
333  for ( i = 1; i < n; i++ )
334  if ( vars[i] != 0 ) m++;
335 
336  DELETE_ARRAY(vars);
337  // do not forget to count our own variable
338  return m+1;
339  }
340 }
#define DELETE_ARRAY(P)
Definition: cf_defs.h:49
static void fillVarsRec(const CanonicalForm &f, int *vars)
static void fillVarsRec ( const CanonicalForm & f, int * vars )
Definition: cf_ops.cc:296

◆ getVars()

CanonicalForm getVars ( const CanonicalForm f)

CanonicalForm getVars ( const CanonicalForm & f )

getVars() - get polynomial variables of f.

Return the product of all of them, 1 if there are not any.

Definition at line 350 of file cf_ops.cc.

351 {
352  int n;
353  if ( f.inCoeffDomain() )
354  return 1;
355  else if ( (n = f.level()) == 1 )
356  return Variable( 1 );
357  else
358  {
359  int * vars = NEW_ARRAY(int, n+1);
360  int i;
361  for ( i = n; i >= 0; i-- ) vars[i] = 0;
362 
363  // look for variables
364  for ( CFIterator I = f; I.hasTerms(); ++I )
365  fillVarsRec( I.coeff(), vars );
366 
367  // multiply them all
368  CanonicalForm result = 1;
369  for ( i = n; i > 0; i-- )
370  if ( vars[i] != 0 ) result *= Variable( i );
371 
372  DELETE_ARRAY(vars);
373  // do not forget our own variable
374  return f.mvar() * result;
375  }
376 }

◆ hasFirstAlgVar()

bool hasFirstAlgVar ( const CanonicalForm f,
Variable a 
)

check if poly f contains an algebraic variable a

Definition at line 665 of file cf_ops.cc.

666 {
667  if( f.inBaseDomain() ) // f has NO alg. variable
668  return false;
669  if( f.level()<0 ) // f has only alg. vars, so take the first one
670  {
671  a = f.mvar();
672  return true;
673  }
674  for(CFIterator i=f; i.hasTerms(); i++)
675  if( hasFirstAlgVar( i.coeff(), a ))
676  return true; // 'a' is already set
677  return false;
678 }
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:665

◆ head()

CanonicalForm head ( const CanonicalForm f)
inline

Definition at line 353 of file canonicalform.h.

354 {
355  if ( f.level() > 0 )
356  return power( f.mvar(), f.degree() ) * f.LC();
357  else
358  return f;
359 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation

◆ headdegree()

int headdegree ( const CanonicalForm f)
inline

Definition at line 362 of file canonicalform.h.

362 { return totaldegree( head( f ) ); }
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
CanonicalForm head(const CanonicalForm &f)

◆ icontent()

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

◆ ilog2()

int ilog2 ( const CanonicalForm a)
inline

Definition at line 345 of file canonicalform.h.

345 { return a.ilog2(); }
int ilog2() const
int CanonicalForm::ilog2 () const

◆ is_imm()

int is_imm ( const InternalCF *const  ptr)
inline

Definition at line 62 of file canonicalform.h.

63 {
64  // returns 0 if ptr is not immediate
65  return ( ((int)((intptr_t)ptr)) & 3 );
66 }

◆ isOn()

bool isOn ( int  sw)

switches

Definition at line 1912 of file canonicalform.cc.

1913 {
1914  return cf_glob_switches.isOn( sw );
1915 }
CFSwitches cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.cc:41
bool isOn(int s) const
check if 's' is on
Definition: cf_switches.h:55

◆ lc()

CanonicalForm lc ( const CanonicalForm f)
inline

Definition at line 297 of file canonicalform.h.

297 { return f.lc(); }

◆ Lc()

CanonicalForm Lc ( const CanonicalForm f)
inline

Definition at line 300 of file canonicalform.h.

300 { return f.Lc(); }

◆ LC() [1/2]

CanonicalForm LC ( const CanonicalForm f)
inline

Definition at line 303 of file canonicalform.h.

303 { return f.LC(); }

◆ LC() [2/2]

CanonicalForm LC ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 306 of file canonicalform.h.

306 { return f.LC( v ); }

◆ 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 }

◆ leftShift()

CanonicalForm leftShift ( const CanonicalForm F,
int  n 
)

left shift the main variable of F by n

Returns
if x is the main variable of F the result is F(x^n)

Definition at line 683 of file cf_ops.cc.

684 {
685  ASSERT (n >= 0, "cannot left shift by negative number");
686  if (F.inBaseDomain())
687  return F;
688  if (n == 0)
689  return F;
690  Variable x=F.mvar();
692  for (CFIterator i= F; i.hasTerms(); i++)
693  result += i.coeff()*power (x, i.exp()*n);
694  return result;
695 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inBaseDomain() const

◆ level()

int level ( const CanonicalForm f)
inline

Definition at line 324 of file canonicalform.h.

324 { return f.level(); }

◆ mapdomain()

CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) )

mapdomain() - map all coefficients of f through mf.

Recursively descends down through f to the coefficients which are in a coefficient domain mapping each such coefficient through mf and returns the result.

Definition at line 440 of file cf_ops.cc.

441 {
442  if ( f.inBaseDomain() )
443  return mf( f );
444  else
445  {
446  CanonicalForm result = 0;
447  CFIterator i;
448  Variable x = f.mvar();
449  for ( i = f; i.hasTerms(); i++ )
450  result += power( x, i.exp() ) * mapdomain( i.coeff(), mf );
451  return result;
452  }
453 }
CanonicalForm mapdomain(const CanonicalForm &f, CanonicalForm(*mf)(const CanonicalForm &))
CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) )
Definition: cf_ops.cc:440

◆ mapinto()

CanonicalForm mapinto ( const CanonicalForm f)
inline

Definition at line 348 of file canonicalform.h.

348 { return f.mapinto(); }

◆ mod()

See also
div(), operator%(), CanonicalForm::operator %=()

Definition at line 564 of file cf_inline.cc.

565 {
566  CanonicalForm result( lhs );
567  result.mod( rhs );
568  return result;
569 }

◆ mvar()

Variable mvar ( const CanonicalForm f)
inline

Definition at line 327 of file canonicalform.h.

327 { return f.mvar(); }

◆ num()

CanonicalForm num ( const CanonicalForm f)
inline

Definition at line 330 of file canonicalform.h.

330 { return f.num(); }

◆ Off()

void Off ( int  sw)

switches

Definition at line 1905 of file canonicalform.cc.

1906 {
1907  cf_glob_switches.Off( sw );
1908 }
void Off(int s)
switch 's' off
Definition: cf_switches.h:53

◆ On()

void On ( int  sw)

switches

Definition at line 1898 of file canonicalform.cc.

1899 {
1900  cf_glob_switches.On( sw );
1901 }
void On(int s)
switch 's' on
Definition: cf_switches.h:51

◆ operator%()

See also
CanonicalForm::operator %=()

Definition at line 540 of file cf_inline.cc.

541 {
542  CanonicalForm result( lhs );
543  result %= rhs;
544  return result;
545 }

◆ operator*()

CF_INLINE CanonicalForm operator* ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
See also
CanonicalForm::operator *=()

Definition at line 517 of file cf_inline.cc.

518 {
519  CanonicalForm result( lhs );
520  result *= rhs;
521  return result;
522 }

◆ operator+()

CF_INLINE CanonicalForm operator+ ( const CanonicalForm lhs,
const CanonicalForm rhs 
)

CF_INLINE CanonicalForm operator +, -, *, /, % ( const CanonicalForm & lhs, const CanonicalForm & rhs )

operators +, -, *, /, %(), div(), mod() - binary arithmetic operators.

The binary operators have their standard (mathematical) semantics. As explained for the corresponding arithmetic assignment operators, the operators ‘/’ and ‘%’ return the quotient resp. remainder of (polynomial) division with remainder, whereas ‘div()’ and ‘mod()’ may be used for exact division and term-wise remaindering, resp.

It is faster to use the arithmetic assignment operators (e.g., ‘f += g;’) instead of the binary operators (‘f = f+g;’ ).

Type info:

lhs, rhs: CurrentPP

There are weaker preconditions for some cases (e.g., arithmetic operations with elements from Q or Z work in any domain), but type ‘CurrentPP’ is the only one guaranteed to work for all cases.

Developers note:

All binary operators have their corresponding ‘CanonicalForm’ assignment operators (e.g., ‘operator +()’ corresponds to ‘CanonicalForm::operator +=()’, ‘div()’ corresponds to `CanonicalFormdiv()).

And that is how they are implemented, too: Each of the binary operators first creates a copy of ‘lhs’, adds ‘rhs’ to this copy using the assignment operator, and returns the result.

See also
CanonicalForm::operator +=()

Definition at line 496 of file cf_inline.cc.

497 {
498  CanonicalForm result( lhs );
499  result += rhs;
500  return result;
501 }

◆ operator-()

Definition at line 505 of file cf_inline.cc.

506 {
507  CanonicalForm result( lhs );
508  result -= rhs;
509  return result;
510 }

◆ operator/()

See also
CanonicalForm::operator /=()

Definition at line 529 of file cf_inline.cc.

530 {
531  CanonicalForm result( lhs );
532  result /= rhs;
533  return result;
534 }

◆ power() [1/2]

CanonicalForm power ( const CanonicalForm f,
int  n 
)

exponentiation

Definition at line 1837 of file canonicalform.cc.

1838 {
1839  ASSERT( n >= 0, "illegal exponent" );
1840  if ( f.isZero() )
1841  return CanonicalForm(0L);
1842  else if ( f.isOne() )
1843  return f;
1844  else if ( f == -1 )
1845  {
1846  if ( n % 2 == 0 )
1847  return CanonicalForm(1L);
1848  else
1849  return CanonicalForm(-1L);
1850  }
1851  else if ( n == 0 )
1852  return CanonicalForm(1L);
1853 
1854  //else if (f.inGF())
1855  //{
1856  //}
1857  else
1858  {
1859  CanonicalForm g,h;
1860  h=f;
1861  while(n%2==0)
1862  {
1863  h*=h;
1864  n/=2;
1865  }
1866  g=h;
1867  while(1)
1868  {
1869  n/=2;
1870  if(n==0)
1871  return g;
1872  h*=h;
1873  if(n%2!=0) g*=h;
1874  }
1875  }
1876 }
static Poly * h
Definition: janet.cc:972

◆ power() [2/2]

CanonicalForm power ( const Variable v,
int  n 
)

exponentiation

Definition at line 1880 of file canonicalform.cc.

1881 {
1882  //ASSERT( n >= 0, "illegal exponent" );
1883  if ( n == 0 )
1884  return 1;
1885  else if ( n == 1 )
1886  return v;
1887  else if (( v.level() < 0 ) && (hasMipo(v)))
1888  {
1889  CanonicalForm result( v, n-1 );
1890  return result * v;
1891  }
1892  else
1893  return CanonicalForm( v, n );
1894 }
bool hasMipo(const Variable &alpha)
Definition: variable.cc:226

◆ 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 }

◆ reduce()

polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of f are reduced modulo M

Definition at line 646 of file cf_ops.cc.

647 {
648  if(f.inBaseDomain() || f.level() < M.level())
649  return f;
650  if(f.level() == M.level())
651  {
652  if(f.degree() < M.degree())
653  return f;
654  CanonicalForm tmp = mod (f, M);
655  return tmp;
656  }
657  // here: f.level() > M.level()
658  CanonicalForm result = 0;
659  for(CFIterator i=f; i.hasTerms(); i++)
660  result += reduce(i.coeff(),M) * power(f.mvar(),i.exp());
661  return result;
662 }
CF_NO_INLINE CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
Definition: cf_inline.cc:564
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
Definition: cf_ops.cc:646
#define M
Definition: sirandom.c:24

◆ replacevar()

CanonicalForm replacevar ( const CanonicalForm f,
const Variable x1,
const Variable x2 
)

CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 )

replacevar() - replace all occurences of x1 in f by x2.

In contrast to swapvar(), x1 may be an algebraic variable, but x2 must be a polynomial variable.

Definition at line 271 of file cf_ops.cc.

272 {
273  //ASSERT( x2.level() > 0, "cannot replace with algebraic variable" );
274  if ( f.inBaseDomain() || x1 == x2 || ( x1 > f.mvar() ) )
275  return f;
276  else
277  {
278  sv_x1 = x1;
279  sv_x2 = x2;
280  return replacevar_between( f );
281  }
282 }
static Variable sv_x2
Definition: cf_ops.cc:43
static Variable sv_x1
static Variable sv_x1, sv_x2;
Definition: cf_ops.cc:43
static CanonicalForm replacevar_between(const CanonicalForm &f)
replacevar_between() - replace occurences of sv_x1 in f with sv_x2.
Definition: cf_ops.cc:233

◆ setCharacteristic() [1/3]

void setCharacteristic ( int  c)

Definition at line 23 of file cf_char.cc.

24 {
25  if ( c == 0 )
26  {
27  theDegree = 0;
30  }
31  else
32  {
33  theDegree = 1;
37  if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
38  ff_setprime( c );
39  }
40 }
#define FiniteFieldDomain
Definition: cf_defs.h:23
#define IntegerDomain
Definition: cf_defs.h:25
int cf_getNumSmallPrimes()
Definition: cf_primes.cc:34
int cf_getSmallPrime(int i)
Definition: cf_primes.cc:28
void(* factoryError)(const char *s)
Definition: cf_util.cc:75
static void settype(int type)
Definition: cf_factory.h:29
bool ff_big
Definition: ffops.cc:16
void ff_setprime(const int p)
Definition: ffops.cc:19

◆ setCharacteristic() [2/3]

void setCharacteristic ( int  c,
int  n 
)

◆ setCharacteristic() [3/3]

void setCharacteristic ( int  c,
int  n,
char  name 
)

Definition at line 42 of file cf_char.cc.

43 {
44  ASSERT( c != 0 && n > 1, "illegal GF(q)" );
45  setCharacteristic( c );
46  gf_setcharacteristic( c, n, name );
47  theDegree = n;
49 }
void setCharacteristic(int c)
Definition: cf_char.cc:23
char name(const Variable &v)
Definition: factory.h:180
void gf_setcharacteristic(int p, int n, char name)
Definition: gfops.cc:219

◆ sign()

int sign ( const CanonicalForm a)
inline

Definition at line 336 of file canonicalform.h.

336 { return a.sign(); }
int sign() const
int CanonicalForm::sign () const

◆ size() [1/2]

int size ( const CanonicalForm f)

int size ( const CanonicalForm & f )

size() - return number of monomials in f which are in an coefficient domain.

Returns one if f is in an coefficient domain.

Definition at line 628 of file cf_ops.cc.

629 {
630  if ( f.inCoeffDomain() )
631  return 1;
632  else
633  {
634  int result = 0;
635  CFIterator i;
636  for ( i = f; i.hasTerms(); i++ )
637  result += size( i.coeff() );
638  return result;
639  }
640 }
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600

◆ size() [2/2]

int size ( const CanonicalForm f,
const Variable v 
)

int size ( const CanonicalForm & f, const Variable & v )

size() - count number of monomials of f with level higher or equal than level of v.

Returns one if f is in an base domain.

Definition at line 600 of file cf_ops.cc.

601 {
602  if ( f.inBaseDomain() )
603  return 1;
604 
605  if ( f.mvar() < v )
606  // polynomials with level < v1 are counted as coefficients
607  return 1;
608  else
609  {
610  CFIterator i;
611  int result = 0;
612  // polynomials with level > v2 are not counted al all
613  for ( i = f; i.hasTerms(); i++ )
614  result += size( i.coeff(), v );
615  return result;
616  }
617 }

◆ sqrt()

CanonicalForm sqrt ( const CanonicalForm a)
inline

Definition at line 342 of file canonicalform.h.

342 { return a.sqrt(); }
CanonicalForm sqrt() const
CanonicalForm CanonicalForm::sqrt () const.

◆ swapvar()

CanonicalForm swapvar ( const CanonicalForm f,
const Variable x1,
const Variable x2 
)

swapvar() - swap variables x1 and x2 in f.

Returns the image of f under the map which maps x1 to x2 and x2 to x1. This is done quite efficiently because it is used really often. x1 and x2 should be polynomial variables.

Definition at line 168 of file cf_ops.cc.

169 {
170  ASSERT( x1.level() > 0 && x2.level() > 0, "cannot swap algebraic Variables" );
171  if ( f.inCoeffDomain() || x1 == x2 || ( x1 > f.mvar() && x2 > f.mvar() ) )
172  return f;
173  else
174  {
175  CanonicalForm result = 0;
176  if ( x1 > x2 )
177  {
178  sv_x1 = x2; sv_x2 = x1;
179  }
180  else
181  {
182  sv_x1 = x1; sv_x2 = x2;
183  }
184  if ( f.mvar() < sv_x2 )
185  // we only have to replace sv_x1 by sv_x2
186  swapvar_between( f, result, 1, 0 );
187  else
188  // we really have to swap variables
189  swapvar_rec( f, result, 1 );
190  return result;
191  }
192 }
static void swapvar_rec(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term)
swapvar_between() - swap occurences of sv_x1 and sv_x2 in f.
Definition: cf_ops.cc:113
static void swapvar_between(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term, int expx2)
static void swapvar_between ( const CanonicalForm & f, CanonicalForm & result, const CanonicalForm & ...
Definition: cf_ops.cc:58

◆ tailcoeff() [1/2]

CanonicalForm tailcoeff ( const CanonicalForm f)
inline

Definition at line 318 of file canonicalform.h.

318 { return f.tailcoeff(); }

◆ tailcoeff() [2/2]

CanonicalForm tailcoeff ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 321 of file canonicalform.h.

321 { return f.tailcoeff(v); }

◆ taildegree()

int taildegree ( const CanonicalForm f)
inline

Definition at line 315 of file canonicalform.h.

315 { return f.taildegree(); }

◆ totaldegree() [1/2]

int totaldegree ( const CanonicalForm f)

int totaldegree ( const CanonicalForm & f )

totaldegree() - return the total degree of f.

If f is zero, return -1. If f is in a coefficient domain, return 0. Otherwise return the total degree of f in all polynomial variables.

Definition at line 523 of file cf_ops.cc.

524 {
525  if ( f.isZero() )
526  return -1;
527  else if ( f.inCoeffDomain() )
528  return 0;
529  else
530  {
531  CFIterator i;
532  int cdeg = 0, dummy;
533  // calculate maximum over all coefficients of f, taking
534  // in account our own exponent
535  for ( i = f; i.hasTerms(); i++ )
536  if ( (dummy = totaldegree( i.coeff() ) + i.exp()) > cdeg )
537  cdeg = dummy;
538  return cdeg;
539  }
540 }
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523

◆ totaldegree() [2/2]

int totaldegree ( const CanonicalForm f,
const Variable v1,
const Variable v2 
)

int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 )

totaldegree() - return the total degree of f as a polynomial in the polynomial variables between v1 and v2 (inclusively).

If f is zero, return -1. If f is in a coefficient domain, return 0. Also, return 0 if v1 > v2. Otherwise, take f to be a polynomial in the polynomial variables between v1 and v2 and return its total degree.

Definition at line 554 of file cf_ops.cc.

555 {
556  if ( f.isZero() )
557  return -1;
558  else if ( v1 > v2 )
559  return 0;
560  else if ( f.inCoeffDomain() )
561  return 0;
562  else if ( f.mvar() < v1 )
563  return 0;
564  else if ( f.mvar() == v1 )
565  return f.degree();
566  else if ( f.mvar() > v2 )
567  {
568  // v2's level is larger than f's level, descend down
569  CFIterator i;
570  int cdeg = 0, dummy;
571  // calculate maximum over all coefficients of f
572  for ( i = f; i.hasTerms(); i++ )
573  if ( (dummy = totaldegree( i.coeff(), v1, v2 )) > cdeg )
574  cdeg = dummy;
575  return cdeg;
576  }
577  else
578  {
579  // v1 < f.mvar() <= v2
580  CFIterator i;
581  int cdeg = 0, dummy;
582  // calculate maximum over all coefficients of f, taking
583  // in account our own exponent
584  for ( i = f; i.hasTerms(); i++ )
585  if ( (dummy = totaldegree( i.coeff(), v1, v2 ) + i.exp()) > cdeg )
586  cdeg = dummy;
587  return cdeg;
588  }
589 }

◆ 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 }
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:230
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354