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

#define CF_INLINE

Definition at line 53 of file canonicalform.h.

#define CF_INLINE

Definition at line 53 of file canonicalform.h.

#define CF_NO_INLINE

Definition at line 44 of file canonicalform.h.

#define ISTREAM   std::istream

Definition at line 17 of file canonicalform.h.

#define OSTREAM   std::ostream

Definition at line 16 of file canonicalform.h.

Typedef Documentation

Definition at line 378 of file canonicalform.h.

Definition at line 379 of file canonicalform.h.

Definition at line 380 of file canonicalform.h.

Definition at line 386 of file canonicalform.h.

Definition at line 381 of file canonicalform.h.

typedef List<CFFactor> CFFList

Definition at line 382 of file canonicalform.h.

Definition at line 383 of file canonicalform.h.

Definition at line 384 of file canonicalform.h.

Definition at line 385 of file canonicalform.h.

Definition at line 387 of file canonicalform.h.

typedef Array<int> Intarray

Definition at line 394 of file canonicalform.h.

typedef List<int> IntList

Definition at line 390 of file canonicalform.h.

Definition at line 391 of file canonicalform.h.

Definition at line 388 of file canonicalform.h.

Definition at line 389 of file canonicalform.h.

typedef List<Variable> Varlist

Definition at line 392 of file canonicalform.h.

Definition at line 393 of file canonicalform.h.

Function Documentation

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

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 mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
factory&#39;s class for variables
Definition: variable.h:32
factory&#39;s main class
Definition: canonicalform.h:75
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
Variable x
Definition: cfModGcd.cc:4023
#define ASSERT(expression, message)
Definition: cf_assert.h:99
p exp[i]
Definition: DebugPrint.cc:39
return result
Definition: facAbsBiFact.cc:76

Definition at line 1759 of file canonicalform.cc.

1760 {
1761  if ( f.isZero() || g.isZero() )
1762  return CanonicalForm( 0 );
1763 /*
1764  else if (f.isOne())
1765  return g;
1766  else if (g.isOne())
1767  return f;
1768 */
1769  else
1770  return (f / bgcd( f, g )) * g;
1771 }
factory&#39;s main class
Definition: canonicalform.h:75
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
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 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory&#39;s main class
Definition: canonicalform.h:75
bool inExtension() const
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
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
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
bool inPolyDomain() const
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:262
return result
Definition: facAbsBiFact.cc:76
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 }
int level() const
Definition: variable.h:49
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory&#39;s class for variables
Definition: variable.h:32
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
FILE * f
Definition: checklibs.c:7
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:180
bool inBaseDomain() const
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int degree ( const CanonicalForm f)
inline

Definition at line 305 of file canonicalform.h.

305 { return f.degree(); }
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
int degree ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 308 of file canonicalform.h.

308 { return f.degree( v ); }
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
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 == 0 )
506  degs = new int[level+1];
507  for ( int i = 0; i <= level; i++ )
508  degs[i] = 0;
509  degreesRec( f, degs );
510  return degs;
511  }
512 }
int level(const CanonicalForm &f)
bool inCoeffDomain() const
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
static void degreesRec(const CanonicalForm &f, int *degs)
static void degreesRec ( const CanonicalForm & f, int * degs )
Definition: cf_ops.cc:463
CanonicalForm den ( const CanonicalForm f)
inline

Definition at line 329 of file canonicalform.h.

329 { return f.den(); }
CanonicalForm den() const
den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!) otherwis...
CanonicalForm deriv ( const CanonicalForm f,
const Variable x 
)
inline

Definition at line 335 of file canonicalform.h.

335 { return f.deriv( x ); }
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.

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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76

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);
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: variable.h:32
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
g
Definition: cfModGcd.cc:4031
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
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
FILE * f
Definition: checklibs.c:7
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:720
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
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
factory&#39;s class for variables
Definition: variable.h:32
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
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
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
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 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:7
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
bool isUnivariate() const
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
int getCharacteristic ( )

Definition at line 51 of file cf_char.cc.

52 {
53  return theCharacteristic;
54 }
static int theCharacteristic
Definition: cf_char.cc:20
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
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 }
static int theDegree
Definition: cf_char.cc:21
InternalCF * int2imm_gf(long i)
Definition: imm.h:102
#define ASSERT(expression, message)
Definition: cf_assert.h:99
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 int[ n+1 ];
324  int i;
325  for ( i = 0; i < n; 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 [] vars;
337  // do not forget to count our own variable
338  return m+1;
339  }
340 }
bool inCoeffDomain() const
int level() const
level() returns the level of CO.
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static void fillVarsRec(const CanonicalForm &f, int *vars)
static void fillVarsRec ( const CanonicalForm & f, int * vars )
Definition: cf_ops.cc:296
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 int[ n+1 ];
360  int i;
361  for ( i = 0; i <= n; 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 [] vars;
373  // do not forget our own variable
374  return f.mvar() * result;
375  }
376 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
factory&#39;s class for variables
Definition: variable.h:32
factory&#39;s main class
Definition: canonicalform.h:75
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static void fillVarsRec(const CanonicalForm &f, int *vars)
static void fillVarsRec ( const CanonicalForm & f, int * vars )
Definition: cf_ops.cc:296
return result
Definition: facAbsBiFact.cc:76
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 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
const poly a
Definition: syzextra.cc:212
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:665
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
bool inBaseDomain() const
CanonicalForm head ( const CanonicalForm f)
inline

Definition at line 349 of file canonicalform.h.

350 {
351  if ( f.level() > 0 )
352  return power( f.mvar(), f.degree() ) * f.LC();
353  else
354  return f;
355 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
int level() const
level() returns the level of CO.
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
FILE * f
Definition: checklibs.c:7
CanonicalForm LC() const
int headdegree ( const CanonicalForm f)
inline

Definition at line 358 of file canonicalform.h.

358 { return totaldegree( head( f ) ); }
CanonicalForm head(const CanonicalForm &f)
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
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
int ilog2 ( const CanonicalForm a)
inline

Definition at line 341 of file canonicalform.h.

341 { return a.ilog2(); }
int ilog2() const
int CanonicalForm::ilog2 () const
int is_imm ( const InternalCF *const  ptr)
inline

Definition at line 60 of file canonicalform.h.

61 {
62  // returns 0 if ptr is not immediate
63  return ( ((int)((intptr_t)ptr)) & 3 );
64 }
bool isOn ( int  )

switches

Definition at line 1914 of file canonicalform.cc.

1915 {
1916  return cf_glob_switches.isOn( sw );
1917 }
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
CanonicalForm lc ( const CanonicalForm f)
inline

Definition at line 293 of file canonicalform.h.

293 { return f.lc(); }
CanonicalForm lc() const
CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const.
CanonicalForm Lc ( const CanonicalForm f)
inline

Definition at line 296 of file canonicalform.h.

296 { return f.Lc(); }
CanonicalForm Lc() const
CanonicalForm LC ( const CanonicalForm f)
inline

Definition at line 299 of file canonicalform.h.

299 { return f.LC(); }
CanonicalForm LC() const
CanonicalForm LC ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 302 of file canonicalform.h.

302 { return f.LC( v ); }
CanonicalForm LC() const

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
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 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory&#39;s class for variables
Definition: variable.h:32
factory&#39;s main class
Definition: canonicalform.h:75
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
Variable x
Definition: cfModGcd.cc:4023
bool inBaseDomain() const
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76
int level ( const CanonicalForm f)
inline

Definition at line 320 of file canonicalform.h.

320 { return f.level(); }
int level() const
level() returns the level of CO.

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 power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory&#39;s class for variables
Definition: variable.h:32
factory&#39;s main class
Definition: canonicalform.h:75
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CanonicalForm mapdomain(const CanonicalForm &f, CanonicalForm(*mf)(const CanonicalForm &))
CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ) ...
Definition: cf_ops.cc:440
CF_NO_INLINE int exp() const
get the current exponent
Variable x
Definition: cfModGcd.cc:4023
bool inBaseDomain() const
return result
Definition: facAbsBiFact.cc:76
CanonicalForm mapinto ( const CanonicalForm f)
inline

Definition at line 344 of file canonicalform.h.

344 { return f.mapinto(); }
CanonicalForm mapinto() const
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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76
Variable mvar ( const CanonicalForm f)
inline

Definition at line 323 of file canonicalform.h.

323 { return f.mvar(); }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CanonicalForm num ( const CanonicalForm f)
inline

Definition at line 326 of file canonicalform.h.

326 { return f.num(); }
CanonicalForm num() const
num() returns the numerator of CO if CO is a rational number, CO itself otherwise.
void Off ( int  )

switches

Definition at line 1907 of file canonicalform.cc.

1908 {
1909  cf_glob_switches.Off( sw );
1910 }
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
void On ( int  )

switches

Definition at line 1900 of file canonicalform.cc.

1901 {
1902  cf_glob_switches.On( sw );
1903 }
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76
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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76
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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76

Definition at line 505 of file cf_inline.cc.

506 {
507  CanonicalForm result( lhs );
508  result -= rhs;
509  return result;
510 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76
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 }
factory&#39;s main class
Definition: canonicalform.h:75
return result
Definition: facAbsBiFact.cc:76
CanonicalForm power ( const CanonicalForm f,
int  n 
)

exponentiation

Definition at line 1839 of file canonicalform.cc.

1840 {
1841  ASSERT( n >= 0, "illegal exponent" );
1842  if ( f.isZero() )
1843  return 0;
1844  else if ( f.isOne() )
1845  return f;
1846  else if ( f == -1 )
1847  {
1848  if ( n % 2 == 0 )
1849  return 1;
1850  else
1851  return -1;
1852  }
1853  else if ( n == 0 )
1854  return 1;
1855 
1856  //else if (f.inGF())
1857  //{
1858  //}
1859  else
1860  {
1861  CanonicalForm g,h;
1862  h=f;
1863  while(n%2==0)
1864  {
1865  h*=h;
1866  n/=2;
1867  }
1868  g=h;
1869  while(1)
1870  {
1871  n/=2;
1872  if(n==0)
1873  return g;
1874  h*=h;
1875  if(n%2!=0) g*=h;
1876  }
1877  }
1878 }
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
FILE * f
Definition: checklibs.c:7
#define ASSERT(expression, message)
Definition: cf_assert.h:99
static Poly * h
Definition: janet.cc:978
CanonicalForm power ( const Variable v,
int  n 
)

exponentiation

Definition at line 1882 of file canonicalform.cc.

1883 {
1884  //ASSERT( n >= 0, "illegal exponent" );
1885  if ( n == 0 )
1886  return 1;
1887  else if ( n == 1 )
1888  return v;
1889  else if (( v.level() < 0 ) && (hasMipo(v)))
1890  {
1891  CanonicalForm result( v, n-1 );
1892  return result * v;
1893  }
1894  else
1895  return CanonicalForm( v, n );
1896 }
int level() const
Definition: variable.h:49
factory&#39;s main class
Definition: canonicalform.h:75
bool hasMipo(const Variable &alpha)
Definition: variable.cc:226
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
return result
Definition: facAbsBiFact.cc:76

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

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 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
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
factory&#39;s main class
Definition: canonicalform.h:75
int level() const
level() returns the level of CO.
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
#define M
Definition: sirandom.c:24
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
bool inBaseDomain() const
return result
Definition: facAbsBiFact.cc:76
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 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
static Variable 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
FILE * f
Definition: checklibs.c:7
static Variable sv_x1
static Variable sv_x1, sv_x2;
Definition: cf_ops.cc:43
bool inBaseDomain() const
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 }
int cf_getSmallPrime(int i)
Definition: cf_primes.cc:28
static int theCharacteristic
Definition: cf_char.cc:20
#define IntegerDomain
Definition: cf_defs.h:25
static int theDegree
Definition: cf_char.cc:21
int cf_getNumSmallPrimes()
Definition: cf_primes.cc:34
bool ff_big
Definition: ffops.cc:16
void ff_setprime(const int p)
Definition: ffops.cc:19
static void settype(int type)
Definition: cf_factory.cc:21
void(* factoryError)(const char *s)
Definition: cf_util.cc:75
#define FiniteFieldDomain
Definition: cf_defs.h:23
void setCharacteristic ( int  c,
int  n 
)
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 gf_setcharacteristic(int p, int n, char name)
Definition: gfops.cc:219
static int theDegree
Definition: cf_char.cc:21
void setCharacteristic(int c)
Definition: cf_char.cc:23
char name(const Variable &v)
Definition: variable.h:95
#define GaloisFieldDomain
Definition: cf_defs.h:22
#define ASSERT(expression, message)
Definition: cf_assert.h:99
static void settype(int type)
Definition: cf_factory.cc:21
int sign ( const CanonicalForm a)
inline

Definition at line 332 of file canonicalform.h.

332 { return a.sign(); }
int sign() const
int CanonicalForm::sign () const
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 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
bool inBaseDomain() const
return result
Definition: facAbsBiFact.cc:76
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 }
bool inCoeffDomain() const
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
return result
Definition: facAbsBiFact.cc:76
CanonicalForm sqrt ( const CanonicalForm a)
inline

Definition at line 338 of file canonicalform.h.

338 { return a.sqrt(); }
CanonicalForm sqrt() const
CanonicalForm CanonicalForm::sqrt () const.
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 }
int level() const
Definition: variable.h:49
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
factory&#39;s main class
Definition: canonicalform.h:75
static Variable sv_x2
Definition: cf_ops.cc:43
FILE * f
Definition: checklibs.c:7
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
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 Variable sv_x1
static Variable sv_x1, sv_x2;
Definition: cf_ops.cc:43
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76
CanonicalForm tailcoeff ( const CanonicalForm f)
inline

Definition at line 314 of file canonicalform.h.

314 { return f.tailcoeff(); }
CanonicalForm tailcoeff() const
tailcoeff() - return least coefficient
CanonicalForm tailcoeff ( const CanonicalForm f,
const Variable v 
)
inline

Definition at line 317 of file canonicalform.h.

317 { return f.tailcoeff(v); }
CanonicalForm tailcoeff() const
tailcoeff() - return least coefficient
int taildegree ( const CanonicalForm f)
inline

Definition at line 311 of file canonicalform.h.

311 { return f.taildegree(); }
int taildegree() const
taildegree() returns -1 for the zero polynomial, 0 if CO is in a base domain, otherwise the least deg...
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 }
bool inCoeffDomain() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
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 }
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inCoeffDomain() const
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int exp() const
get the current exponent
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 }
int level() const
Definition: variable.h:49
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
factory&#39;s main class
Definition: canonicalform.h:75
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:230
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
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