Loading...
Searching...
No Matches
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 "si_log2.h"`
`#include "omalloc/omallocClass.h"`
`#include "cf_inline.cc"`

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 inline

## Typedefs

typedef AFactor< CanonicalForm > | CFAFactor
typedef List< CFAFactor > | CFAFList
typedef ListIterator< CFAFactor > | CFAFListIterator
typedef Factor< CanonicalForm > | CFFactor
typedef List< CFFactor > | CFFList
typedef ListIterator< CFFactor > | CFFListIterator
typedef List< CanonicalForm > | CFList
typedef ListIterator< CanonicalForm > | CFListIterator
typedef Array< CanonicalForm > | CFArray
typedef Matrix< CanonicalForm > | CFMatrix
typedef List< CFList > | ListCFList
typedef ListIterator< CFList > | ListCFListIterator
typedef List< int > | IntList
typedef ListIterator< int > | IntListIterator
typedef List< Variable > | Varlist
typedef ListIterator< Variable > | VarlistIterator
typedef Array< int > | Intarray

## Functions

int | is_imm (const InternalCF *const ptr)
CF_INLINE FACTORY_PUBLIC CanonicalForm | operator+ (const CanonicalForm &, const CanonicalForm &)
| CF_INLINE CanonicalForm operator +, -, *, /, % ( const CanonicalForm & lhs, const CanonicalForm & rhs ).
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm | operator- (const CanonicalForm &, const CanonicalForm &)
CF_INLINE FACTORY_PUBLIC CanonicalForm | operator* (const CanonicalForm &, const CanonicalForm &)
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm | operator/ (const CanonicalForm &, const CanonicalForm &)
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm | operator% (const CanonicalForm &, const CanonicalForm &)
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm | div (const CanonicalForm &, const CanonicalForm &)
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm | mod (const CanonicalForm &, const CanonicalForm &)
CanonicalForm FACTORY_PUBLIC | blcm (const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm FACTORY_PUBLIC | power (const CanonicalForm &f, int n)
| exponentiation
CanonicalForm FACTORY_PUBLIC | power (const Variable &v, int n)
| exponentiation
CanonicalForm FACTORY_PUBLIC | gcd (const CanonicalForm &, const CanonicalForm &)
CanonicalForm FACTORY_PUBLIC | gcd_poly (const CanonicalForm &f, const CanonicalForm &g)
| CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g ).
CanonicalForm FACTORY_PUBLIC | lcm (const CanonicalForm &, const CanonicalForm &)
| CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g ).
CanonicalForm FACTORY_PUBLIC | pp (const CanonicalForm &)
| CanonicalForm pp ( const CanonicalForm & f ).
CanonicalForm FACTORY_PUBLIC | content (const CanonicalForm &)
| CanonicalForm content ( const CanonicalForm & f ).
CanonicalForm FACTORY_PUBLIC | content (const CanonicalForm &, const Variable &)
| CanonicalForm content ( const CanonicalForm & f, const Variable & x ).
CanonicalForm FACTORY_PUBLIC | icontent (const CanonicalForm &f)
| CanonicalForm icontent ( const CanonicalForm & f ).
CanonicalForm FACTORY_PUBLIC | vcontent (const CanonicalForm &f, const Variable &x)
| CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ).
CanonicalForm FACTORY_PUBLIC | swapvar (const CanonicalForm &, const Variable &, const Variable &)
| swapvar() - swap variables x1 and x2 in f.
CanonicalForm FACTORY_PUBLIC | replacevar (const CanonicalForm &, const Variable &, const Variable &)
| CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 ).
int | getNumVars (const CanonicalForm &f)
| int getNumVars ( const CanonicalForm & f )
CanonicalForm | getVars (const CanonicalForm &f)
| CanonicalForm getVars ( const CanonicalForm & f ).
CanonicalForm | apply (const CanonicalForm &f, void(*mf)(CanonicalForm &, int &))
| CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) ).
CanonicalForm | mapdomain (const CanonicalForm &f, CanonicalForm(*mf)(const CanonicalForm &))
| CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ).
int * | degrees (const CanonicalForm &f, int *degs=0)
| int * degrees ( const CanonicalForm & f, int * degs )
int | totaldegree (const CanonicalForm &f)
| int totaldegree ( const CanonicalForm & f )
int | totaldegree (const CanonicalForm &f, const Variable &v1, const Variable &v2)
| int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 )
int | size (const CanonicalForm &f, const Variable &v)
| int size ( const CanonicalForm & f, const Variable & v )
int | size (const CanonicalForm &f)
| int size ( const CanonicalForm & f )
int | size_maxexp (const CanonicalForm &f, int &maxexp)
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
bool | hasFirstAlgVar (const CanonicalForm &f, Variable &a)
| check if poly f contains an algebraic variable a
CanonicalForm | leftShift (const CanonicalForm &F, int n)
| left shift the main variable of F by n
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 FACTORY_PUBLIC | setCharacteristic (int c)
void | setCharacteristic (int c, int n)
void | setCharacteristic (int c, int n, char name)
int FACTORY_PUBLIC | getCharacteristic ()
int | getGFDegree ()
CanonicalForm | getGFGenerator ()
void FACTORY_PUBLIC | On (int)
| switches
void FACTORY_PUBLIC | Off (int)
| switches
bool FACTORY_PUBLIC | isOn (int)
| switches

## Detailed Description

Header for factory's main class CanonicalForm.

Definition in file canonicalform.h.

## Macro Definition Documentation

## CF_INLINE [1/2]

#define CF_INLINE inline

Definition at line 45 of file canonicalform.h.

## CF_INLINE [2/2]

#define CF_INLINE

Definition at line 45 of file canonicalform.h.

## CF_NO_INLINE

#define CF_NO_INLINE

Definition at line 47 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

typedef AFactor<CanonicalForm> CFAFactor

Definition at line 389 of file canonicalform.h.

## CFAFList

typedef List<CFAFactor> CFAFList

Definition at line 390 of file canonicalform.h.

## CFAFListIterator

typedef ListIterator<CFAFactor> CFAFListIterator

Definition at line 391 of file canonicalform.h.

## CFArray

typedef Array<CanonicalForm> CFArray

Definition at line 397 of file canonicalform.h.

## CFFactor

typedef Factor<CanonicalForm> CFFactor

Definition at line 392 of file canonicalform.h.

## CFFList

typedef List<CFFactor> CFFList

Definition at line 393 of file canonicalform.h.

## CFFListIterator

typedef ListIterator<CFFactor> CFFListIterator

Definition at line 394 of file canonicalform.h.

## CFList

typedef List<CanonicalForm> CFList

Definition at line 395 of file canonicalform.h.

## CFListIterator

typedef ListIterator<CanonicalForm> CFListIterator

Definition at line 396 of file canonicalform.h.

## CFMatrix

typedef Matrix<CanonicalForm> CFMatrix

Definition at line 398 of file canonicalform.h.

## Intarray

typedef Array<int> Intarray

Definition at line 405 of file canonicalform.h.

## IntList

typedef List<int> IntList

Definition at line 401 of file canonicalform.h.

## IntListIterator

typedef ListIterator<int> IntListIterator

Definition at line 402 of file canonicalform.h.

## ListCFList

typedef List<CFList> ListCFList

Definition at line 399 of file canonicalform.h.

## ListCFListIterator

typedef ListIterator<CFList> ListCFListIterator

Definition at line 400 of file canonicalform.h.

## Varlist

typedef List<Variable> Varlist

Definition at line 403 of file canonicalform.h.

## VarlistIterator

typedef ListIterator<Variable> VarlistIterator

Definition at line 404 of file canonicalform.h.

## Function Documentation

## apply()

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

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--;
}
i
int i
Definition cfEzgcd.cc:132
f
FILE * f
Definition checklibs.c:9
CanonicalForm
factory's main class
Definition canonicalform.h:86
diff
STATIC_VAR gmp_float * diff
Definition mpr_complex.cc:45

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

Definition at line 402 of file cf_ops.cc.

{
if ( f.inCoeffDomain() )
{
int exp = 0;
CanonicalForm result = f;
mf( result, exp );
ASSERT( exp == 0, "illegal result, do not know what variable to use" );
return result;
}
else
{
CanonicalForm result, coeff;
CFIterator i;
int exp;
Variable x = f.mvar();
for ( i = f; i.hasTerms(); i++ )
{
coeff = i.coeff();
exp = i.exp();
mf( coeff, exp );
if ( ! coeff.isZero() )
result += power( x, exp ) * coeff;
}
return result;
}
}
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition canonicalform.cc:1896
x
Variable x
Definition cfModGcd.cc:4090
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99
CFIterator
class to iterate through CanonicalForm's
Definition cf_iter.h:44
CanonicalForm::isZero
CF_NO_INLINE bool isZero() const
Variable
factory's class for variables
Definition factory.h:127
result
return result
Definition facAbsBiFact.cc:76
exp
gmp_float exp(const gmp_float &a)
Definition mpr_complex.cc:349

## blcm()

CanonicalForm FACTORY_PUBLIC blcm | ( | const CanonicalForm & | f,
|  | const CanonicalForm & | g )

Definition at line 1816 of file canonicalform.cc.

{
if ( f.isZero() || g.isZero() )
return CanonicalForm( 0L );
/*
else if (f.isOne())
return g;
else if (g.isOne())
return f;
*/
else
return (f / bgcd( f, g )) * g;
}
bgcd
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g ).
Definition canonicalform.cc:1648
g
g
Definition cfModGcd.cc:4098

## content() [1/2]

CanonicalForm FACTORY_PUBLIC content | ( | const CanonicalForm & | f | ) |

CanonicalForm content ( const CanonicalForm & f ).

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

Normalizes result.

Definition at line 603 of file cf_gcd.cc.

{
if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
{
CFIterator i = f;
CanonicalForm result = abs( i.coeff() );
i++;
while ( i.hasTerms() && ! result.isOne() )
{
result = gcd( i.coeff(), result );
i++;
}
return result;
}
else
return abs( f );
}
abs
Rational abs(const Rational &a)
Definition GMPrat.cc:436
gcd
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition cf_gcd.cc:685
getReduce
bool getReduce(const Variable &alpha)
Definition variable.cc:232

## content() [2/2]

CanonicalForm FACTORY_PUBLIC 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 629 of file cf_gcd.cc.

{
if (f.inBaseDomain()) return f;
ASSERT( x.level() > 0, "cannot calculate content with respect to algebraic variable" );
Variable y = f.mvar();
if ( y == x )
return cf_content( f, 0 );
else if ( y < x )
return f;
else
return swapvar( content( swapvar( f, y, x ), y ), y, x );
}
swapvar
CanonicalForm FACTORY_PUBLIC swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition cf_ops.cc:168
cf_content
static CanonicalForm cf_content(const CanonicalForm &f, const CanonicalForm &g)
static CanonicalForm cf_content ( const CanonicalForm & f, const CanonicalForm & g )
Definition cf_gcd.cc:578
content
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f ).
Definition cf_gcd.cc:603
y
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53

## degree() [1/2]

int degree | ( | const CanonicalForm & | f | ) |

inline

Definition at line 316 of file canonicalform.h.

{ return f.degree(); }

## degree() [2/2]

int degree | ( | const CanonicalForm & | f,
|  | const Variable & | v )

inline

Definition at line 319 of file canonicalform.h.

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

## 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.

{
if ( f.inCoeffDomain() )
{
if (degs != 0)
return degs;
else
return 0;
}
else
{
int level = f.level();
if ( degs == NULL )
degs = NEW_ARRAY(int,level+1);
for ( int i = level; i >= 0; i-- )
degs[i] = 0;
degreesRec( f, degs );
return degs;
}
}
level
int level(const CanonicalForm &f)
Definition canonicalform.h:331
NEW_ARRAY
#define NEW_ARRAY(T, N)
Definition cf_defs.h:64
degreesRec
static void degreesRec(const CanonicalForm &f, int *degs)
static void degreesRec ( const CanonicalForm & f, int * degs )
Definition cf_ops.cc:463
NULL
#define NULL
Definition omList.c:12

## den()

CanonicalForm den | ( | const CanonicalForm & | f | ) |

inline

Definition at line 340 of file canonicalform.h.

{ return f.den(); }

## deriv()

CanonicalForm deriv | ( | const CanonicalForm & | f,
|  | const Variable & | x )

inline

Definition at line 346 of file canonicalform.h.

{ return f.deriv( x ); }

## div()

CF_NO_INLINE FACTORY_PUBLIC CanonicalForm div | ( | const CanonicalForm & | ,
|  | const CanonicalForm & | )

## gcd()

CanonicalForm FACTORY_PUBLIC gcd | ( | const CanonicalForm & | f,
|  | const CanonicalForm & | g )

Definition at line 685 of file cf_gcd.cc.

{
bool b = f.isZero();
if ( b || g.isZero() )
{
if ( b )
return abs( g );
else
return abs( f );
}
if ( f.inPolyDomain() || g.inPolyDomain() )
{
if ( f.mvar() != g.mvar() )
{
if ( f.mvar() > g.mvar() )
return cf_content( f, g );
else
return cf_content( g, f );
}
if (isOn(SW_USE_QGCD))
{
Variable m;
if (
(getCharacteristic() == 0) &&
(hasFirstAlgVar(f,m) || hasFirstAlgVar(g,m))
)
{
bool on_rational = isOn(SW_RATIONAL);
CanonicalForm r=QGCD(f,g);
On(SW_RATIONAL);
CanonicalForm cdF = bCommonDen( r );
if (!on_rational) Off(SW_RATIONAL);
return cdF*r;
}
}
if ( f.inExtension() && getReduce( f.mvar() ) )
return CanonicalForm(1);
else
{
if ( fdivides( f, g ) )
return abs( f );
else if ( fdivides( g, f ) )
return abs( g );
if ( !( getCharacteristic() == 0 && isOn( SW_RATIONAL ) ) )
{
CanonicalForm d;
d = gcd_poly( f, g );
return abs( d );
}
else
{
CanonicalForm cdF = bCommonDen( f );
CanonicalForm cdG = bCommonDen( g );
CanonicalForm F = f * cdF, G = g * cdG;
Off( SW_RATIONAL );
CanonicalForm l = gcd_poly( F, G );
On( SW_RATIONAL );
return abs( l );
}
}
}
if ( f.inBaseDomain() && g.inBaseDomain() )
return bgcd( f, g );
else
return 1;
}
isOn
bool isOn(int sw)
switches
Definition canonicalform.cc:1971
On
void On(int sw)
switches
Definition canonicalform.cc:1957
Off
void Off(int sw)
switches
Definition canonicalform.cc:1964
hasFirstAlgVar
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition cf_ops.cc:679
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition cf_char.cc:70
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
QGCD
CanonicalForm QGCD(const CanonicalForm &F, const CanonicalForm &G)
gcd over Q(a)
Definition cfGcdAlgExt.cc:731
b
CanonicalForm b
Definition cfModGcd.cc:4111
bCommonDen
CanonicalForm bCommonDen(const CanonicalForm &f)
void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r,...
Definition cf_algorithm.cc:293
fdivides
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
SW_USE_QGCD
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition cf_defs.h:43
SW_RATIONAL
static const int SW_RATIONAL
set to 1 for computations over Q
Definition cf_defs.h:31
gcd_poly
CanonicalForm gcd_poly(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g ).
Definition cf_gcd.cc:492
G
STATIC_VAR TreeM * G
Definition janet.cc:31

## gcd_poly()

CanonicalForm FACTORY_PUBLIC 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 492 of file cf_gcd.cc.

{
CanonicalForm fc, gc;
bool fc_isUnivariate=f.isUnivariate();
bool gc_isUnivariate=g.isUnivariate();
bool fc_and_gc_Univariate=fc_isUnivariate && gc_isUnivariate;
fc = f;
gc = g;
int ch=getCharacteristic();
if ( ch != 0 )
{
if (0) {} // dummy, to be able to build without NTL and FLINT
#if defined(HAVE_FLINT) && ( __FLINT_RELEASE >= 20503)
if ( isOn( SW_USE_FL_GCD_P)
&& (CFFactory::gettype() != GaloisFieldDomain)
#ifdef HAVE_NTL
&& (ch>10) // if we have NTL: it is better for char <11
#endif
&&(!hasAlgVar(fc)) && (!hasAlgVar(gc)))
{
return gcdFlintMP_Zp(fc,gc);
}
#endif
#ifdef HAVE_NTL
if ((!fc_and_gc_Univariate) && (isOn( SW_USE_EZGCD_P )))
{
fc= EZGCD_P (fc, gc);
}
#endif
#if defined(HAVE_NTL) || defined(HAVE_FLINT)
else if (isOn(SW_USE_FF_MOD_GCD) && !fc_and_gc_Univariate)
{
Variable a;
if (hasFirstAlgVar (fc, a) || hasFirstAlgVar (gc, a))
fc=modGCDFq (fc, gc, a);
else if (CFFactory::gettype() == GaloisFieldDomain)
fc=modGCDGF (fc, gc);
else
fc=modGCDFp (fc, gc);
}
#endif
else
fc = gcd_poly_p( fc, gc );
}
else if (!fc_and_gc_Univariate) /* && char==0*/
{
#if defined(HAVE_FLINT) && ( __FLINT_RELEASE >= 20503)
if (( isOn( SW_USE_FL_GCD_0) )
&&(!hasAlgVar(fc)) && (!hasAlgVar(gc)))
{
return gcdFlintMP_QQ(fc,gc);
}
else
#endif
#ifdef HAVE_NTL
if ( isOn( SW_USE_EZGCD ) )
fc= ezgcd (fc, gc);
else
#endif
#if defined(HAVE_NTL) || defined(HAVE_FLINT)
if (isOn(SW_USE_CHINREM_GCD))
fc = modGCDZ( fc, gc);
else
#endif
{
fc = gcd_poly_0( fc, gc );
}
}
else
{
fc = gcd_poly_0( fc, gc );
}
if ((ch>0)&&(!hasAlgVar(fc))) fc/=fc.lc();
return fc;
}
EZGCD_P
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:876
ezgcd
static CanonicalForm ezgcd(const CanonicalForm &FF, const CanonicalForm &GG, REvaluation &b, bool internal)
real implementation of EZGCD over Z
Definition cfEzgcd.cc:498
modGCDFq
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:479
modGCDFp
CanonicalForm modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
Definition cfModGcd.cc:1224
modGCDGF
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 forComputer Algebra" by Geddes...
Definition cfModGcd.cc:873
modGCDZ
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
SW_USE_CHINREM_GCD
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition cf_defs.h:41
SW_USE_FL_GCD_P
static const int SW_USE_FL_GCD_P
set to 1 to use Flints gcd over F_p
Definition cf_defs.h:47
SW_USE_EZGCD_P
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition cf_defs.h:37
SW_USE_FF_MOD_GCD
static const int SW_USE_FF_MOD_GCD
set to 1 to use modular GCD over F_q
Definition cf_defs.h:45
SW_USE_EZGCD
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition cf_defs.h:35
SW_USE_FL_GCD_0
static const int SW_USE_FL_GCD_0
set to 1 to use Flints gcd over Q/Z
Definition cf_defs.h:49
GaloisFieldDomain
#define GaloisFieldDomain
Definition cf_defs.h:18
gcd_poly_0
static CanonicalForm gcd_poly_0(const CanonicalForm &f, const CanonicalForm &g)
Definition cf_gcd.cc:417
gcd_poly_p
static CanonicalForm gcd_poly_p(const CanonicalForm &f, const CanonicalForm &g)
Definition cf_gcd.cc:264
CFFactory::gettype
static int gettype()
Definition cf_factory.h:28
CanonicalForm::lc
CanonicalForm lc() const
CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const.
Definition canonicalform.cc:337
hasAlgVar
int hasAlgVar(const CanonicalForm &f, const Variable &v)
Definition facAlgFuncUtil.cc:322

## getCharacteristic()

int FACTORY_PUBLIC getCharacteristic | ( |  | ) |

Definition at line 70 of file cf_char.cc.

{
return theCharacteristic;
}
theCharacteristic
STATIC_VAR int theCharacteristic
Definition cf_char.cc:25

## getGFDegree()

int getGFDegree | ( |  | ) |

Definition at line 75 of file cf_char.cc.

{
//ASSERT( theDegree > 0, "not in GF(q)" );
return theDegree;
}
theDegree
STATIC_VAR int theDegree
Definition cf_char.cc:26

## getGFGenerator()

CanonicalForm getGFGenerator | ( |  | ) |

Definition at line 81 of file cf_char.cc.

{
ASSERT( theDegree > 1, "not in GF(q)" );
return int2imm_gf( 1 );
}
int2imm_gf
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.

{
int n;
if ( f.inCoeffDomain() )
return 0;
else if ( (n = f.level()) == 1 )
return 1;
else
{
int * vars = NEW_ARRAY(int, n+1);
int i;
for ( i = n-1; i >=0; i-- ) vars[i] = 0;
// look for variables
for ( CFIterator I = f; I.hasTerms(); ++I )
fillVarsRec( I.coeff(), vars );
// count them
int m = 0;
for ( i = 1; i < n; i++ )
if ( vars[i] != 0 ) m++;
DELETE_ARRAY(vars);
// do not forget to count our own variable
return m+1;
}
}
DELETE_ARRAY
#define DELETE_ARRAY(P)
Definition cf_defs.h:65
fillVarsRec
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.

{
int n;
if ( f.inCoeffDomain() )
return 1;
else if ( (n = f.level()) == 1 )
return Variable( 1 );
else
{
int * vars = NEW_ARRAY(int, n+1);
int i;
for ( i = n; i >= 0; i-- ) vars[i] = 0;
// look for variables
for ( CFIterator I = f; I.hasTerms(); ++I )
fillVarsRec( I.coeff(), vars );
// multiply them all
CanonicalForm result = 1;
for ( i = n; i > 0; i-- )
if ( vars[i] != 0 ) result *= Variable( i );
DELETE_ARRAY(vars);
// do not forget our own variable
return f.mvar() * result;
}
}

## hasFirstAlgVar()

bool hasFirstAlgVar | ( | const CanonicalForm & | f,
|  | Variable & | a )

check if poly f contains an algebraic variable a

Definition at line 679 of file cf_ops.cc.

{
if( f.inBaseDomain() ) // f has NO alg. variable
return false;
if( f.level()<0 ) // f has only alg. vars, so take the first one
{
a = f.mvar();
return true;
}
for(CFIterator i=f; i.hasTerms(); i++)
if( hasFirstAlgVar( i.coeff(), a ))
return true; // 'a' is already set
return false;
}
hasFirstAlgVar
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition cf_ops.cc:679

## head()

CanonicalForm head | ( | const CanonicalForm & | f | ) |

inline

Definition at line 360 of file canonicalform.h.

{
if ( f.level() > 0 )
return power( f.mvar(), f.degree() ) * f.LC();
else
return f;
}
power
CanonicalForm FACTORY_PUBLIC power(const CanonicalForm &f, int n)
exponentiation
Definition canonicalform.cc:1896

## headdegree()

int headdegree | ( | const CanonicalForm & | f | ) |

inline

Definition at line 369 of file canonicalform.h.

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

## icontent()

CanonicalForm FACTORY_PUBLIC 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 74 of file cf_gcd.cc.

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

## ilog2()

int ilog2 | ( | const CanonicalForm & | a | ) |

inline

Definition at line 352 of file canonicalform.h.

{ return a.ilog2(); }
CanonicalForm::ilog2
int ilog2() const
int CanonicalForm::ilog2 () const
Definition canonicalform.cc:1417

## is_imm()

int is_imm | ( | const InternalCF *const | ptr | ) |

inline

Definition at line 65 of file canonicalform.h.

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

## isOn()

bool FACTORY_PUBLIC isOn | ( | int | sw | ) |

switches

Definition at line 1971 of file canonicalform.cc.

{
return cf_glob_switches.isOn( sw );
}
cf_glob_switches
INST_VAR CFSwitches cf_glob_switches
Definition cf_switches.cc:54

## LC() [1/2]

CanonicalForm LC | ( | const CanonicalForm & | f | ) |

inline

Definition at line 310 of file canonicalform.h.

{ return f.LC(); }

## LC() [2/2]

CanonicalForm LC | ( | const CanonicalForm & | f,
|  | const Variable & | v )

inline

Definition at line 313 of file canonicalform.h.

{ return f.LC( v ); }

## Lc()

CanonicalForm Lc | ( | const CanonicalForm & | f | ) |

inline

Definition at line 307 of file canonicalform.h.

{ return f.Lc(); }

## lc()

CanonicalForm lc | ( | const CanonicalForm & | f | ) |

inline

Definition at line 304 of file canonicalform.h.

{ return f.lc(); }

## lcm()

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

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

{
if ( f.isZero() || g.isZero() )
return 0;
else
return ( f / gcd( f, g ) ) * g;
}

## 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 697 of file cf_ops.cc.

{
ASSERT (n >= 0, "cannot left shift by negative number");
if (F.inBaseDomain())
return F;
if (n == 0)
return F;
Variable x=F.mvar();
CanonicalForm result= 0;
for (CFIterator i= F; i.hasTerms(); i++)
result += i.coeff()*power (x, i.exp()*n);
return result;
}
CanonicalForm::mvar
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
Definition canonicalform.cc:593
CanonicalForm::inBaseDomain
bool inBaseDomain() const
Definition canonicalform.cc:104

## level()

int level | ( | const CanonicalForm & | f | ) |

inline

Definition at line 331 of file canonicalform.h.

{ return f.level(); }

## mapdomain()

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

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.

{
if ( f.inBaseDomain() )
return mf( f );
else
{
CanonicalForm result = 0;
CFIterator i;
Variable x = f.mvar();
for ( i = f; i.hasTerms(); i++ )
result += power( x, i.exp() ) * mapdomain( i.coeff(), mf );
return result;
}
}
mapdomain
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 355 of file canonicalform.h.

{ return f.mapinto(); }

## mod()

CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod | ( | const CanonicalForm & | ,
|  | const CanonicalForm & | )

## mvar()

Variable mvar | ( | const CanonicalForm & | f | ) |

inline

Definition at line 334 of file canonicalform.h.

{ return f.mvar(); }

## num()

CanonicalForm num | ( | const CanonicalForm & | f | ) |

inline

Definition at line 337 of file canonicalform.h.

{ return f.num(); }

## Off()

void FACTORY_PUBLIC Off | ( | int | sw | ) |

switches

Definition at line 1964 of file canonicalform.cc.

{
cf_glob_switches.Off( sw );
}

## On()

void FACTORY_PUBLIC On | ( | int | sw | ) |

switches

Definition at line 1957 of file canonicalform.cc.

{
cf_glob_switches.On( sw );
}

## operator%()

CF_NO_INLINE FACTORY_PUBLIC CanonicalForm operator% | ( | const CanonicalForm & | ,
|  | const CanonicalForm & | )

## operator*()

CF_INLINE FACTORY_PUBLIC CanonicalForm operator* | ( | const CanonicalForm & | lhs,
|  | const CanonicalForm & | rhs )

See also
  CanonicalForm::operator *=()

Definition at line 524 of file cf_inline.cc.

{
CanonicalForm result( lhs );
result *= rhs;
return result;
}

## operator+()

CF_INLINE FACTORY_PUBLIC 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 503 of file cf_inline.cc.

{
CanonicalForm result( lhs );
result += rhs;
return result;
}

## operator-()

CF_NO_INLINE FACTORY_PUBLIC CanonicalForm operator- | ( | const CanonicalForm & | ,
|  | const CanonicalForm & | )

## operator/()

CF_NO_INLINE FACTORY_PUBLIC CanonicalForm operator/ | ( | const CanonicalForm & | ,
|  | const CanonicalForm & | )

## power() [1/2]

CanonicalForm FACTORY_PUBLIC power | ( | const CanonicalForm & | f,
|  | int | n )

exponentiation

Definition at line 1896 of file canonicalform.cc.

{
ASSERT( n >= 0, "illegal exponent" );
if ( f.isZero() )
return CanonicalForm(0L);
else if ( f.isOne() )
return f;
else if ( f == -1 )
{
if ( n % 2 == 0 )
return CanonicalForm(1L);
else
return CanonicalForm(-1L);
}
else if ( n == 0 )
return CanonicalForm(1L);
//else if (f.inGF())
//{
//}
else
{
CanonicalForm g,h;
h=f;
while(n%2==0)
{
h*=h;
n/=2;
}
g=h;
while(1)
{
n/=2;
if(n==0)
return g;
h*=h;
if(n%2!=0) g*=h;
}
}
}
h
STATIC_VAR Poly * h
Definition janet.cc:971

## power() [2/2]

CanonicalForm FACTORY_PUBLIC power | ( | const Variable & | v,
|  | int | n )

exponentiation

Definition at line 1939 of file canonicalform.cc.

{
//ASSERT( n >= 0, "illegal exponent" );
if ( n == 0 )
return 1;
else if ( n == 1 )
return v;
else if (( v.level() < 0 ) && (hasMipo(v)))
{
CanonicalForm result( v, n-1 );
return result * v;
}
else
return CanonicalForm( v, n );
}
hasMipo
bool hasMipo(const Variable &alpha)
Definition variable.cc:226

## pp()

CanonicalForm FACTORY_PUBLIC pp | ( | const CanonicalForm & | f | ) |

CanonicalForm pp ( const CanonicalForm & f ).

pp() - return primitive part of f.

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

Definition at line 676 of file cf_gcd.cc.

{
if ( f.isZero() )
return f;
else
return f / content( f );
}

## reduce()

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

Definition at line 660 of file cf_ops.cc.

{
if(f.inBaseDomain() || f.level() < M.level())
return f;
if(f.level() == M.level())
{
if(f.degree() < M.degree())
return f;
CanonicalForm tmp = mod (f, M);
return tmp;
}
// here: f.level() > M.level()
CanonicalForm result = 0;
for(CFIterator i=f; i.hasTerms(); i++)
result += reduce(i.coeff(),M) * power(f.mvar(),i.exp());
return result;
}
mod
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
reduce
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:660
M
#define M
Definition sirandom.c:25

## replacevar()

CanonicalForm FACTORY_PUBLIC 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.

{
//ASSERT( x2.level() > 0, "cannot replace with algebraic variable" );
if ( f.inBaseDomain() || x1 == x2 || ( x1 > f.mvar() ) )
return f;
else
{
sv_x1 = x1;
sv_x2 = x2;
return replacevar_between( f );
}
}
sv_x2
STATIC_INST_VAR Variable sv_x2
Definition cf_ops.cc:43
replacevar_between
static CanonicalForm replacevar_between(const CanonicalForm &f)
replacevar_between() - replace occurences of sv_x1 in f with sv_x2.
Definition cf_ops.cc:233
sv_x1
STATIC_INST_VAR Variable sv_x1
static Variable sv_x1, sv_x2;
Definition cf_ops.cc:43

## setCharacteristic() [1/3]

void FACTORY_PUBLIC setCharacteristic | ( | int | c | ) |

Definition at line 28 of file cf_char.cc.

{
if ( c == 0 )
{
theDegree = 0;
CFFactory::settype( IntegerDomain );
theCharacteristic = 0;
}
else
{
theDegree = 1;
CFFactory::settype( FiniteFieldDomain );
ff_big = c > cf_getSmallPrime( cf_getNumSmallPrimes()-1 );
if (c!=theCharacteristic)
{
if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
ff_setprime( c );
}
theCharacteristic = c;
}
}
FiniteFieldDomain
#define FiniteFieldDomain
Definition cf_defs.h:19
IntegerDomain
#define IntegerDomain
Definition cf_defs.h:21
cf_getNumSmallPrimes
int cf_getNumSmallPrimes()
Definition cf_primes.cc:34
cf_getSmallPrime
int cf_getSmallPrime(int i)
Definition cf_primes.cc:28
factoryError
VAR void(* factoryError)(const char *s)
Definition cf_util.cc:80
CFFactory::settype
static void settype(int type)
Definition cf_factory.h:29
ff_big
VAR bool ff_big
Definition ffops.cc:25
ff_setprime
void ff_setprime(const int p)
Definition ffops.cc:28

## setCharacteristic() [2/3]

void setCharacteristic | ( | int | c,
|  | int | n )

## setCharacteristic() [3/3]

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

Definition at line 61 of file cf_char.cc.

{
ASSERT( c != 0 && n > 1, "illegal GF(q)" );
setCharacteristic( c );
gf_setcharacteristic( c, n, name );
theDegree = n;
CFFactory::settype( GaloisFieldDomain );
}
setCharacteristic
void setCharacteristic(int c)
Definition cf_char.cc:28
name
char name(const Variable &v)
Definition factory.h:189
gf_setcharacteristic
void gf_setcharacteristic(int p, int n, char name)
Definition gfops.cc:202

## sign()

int sign | ( | const CanonicalForm & | a | ) |

inline

Definition at line 343 of file canonicalform.h.

{ return a.sign(); }
CanonicalForm::sign
int sign() const
int CanonicalForm::sign () const
Definition canonicalform.cc:1360

## 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 627 of file cf_ops.cc.

{
if ( f.inCoeffDomain() )
return 1;
else
{
int result = 0;
CFIterator i;
for ( i = f; i.hasTerms(); i++ )
result += size( i.coeff() );
return result;
}
}
size
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.

{
if ( f.inBaseDomain() )
return 1;
if ( f.mvar() < v )
// polynomials with level < v1 are counted as coefficients
return 1;
else
{
CFIterator i;
int result = 0;
// polynomials with level > v2 are not counted al all
for ( i = f; i.hasTerms(); i++ )
result += size( i.coeff(), v );
return result;
}
}

## size_maxexp()

int size_maxexp | ( | const CanonicalForm & | f,
|  | int & | maxexp )

Definition at line 641 of file cf_ops.cc.

{
if ( f.inCoeffDomain() )
return 1;
else
{
if (f.degree()>maxexp) maxexp=f.degree();
int result = 0;
CFIterator i;
for ( i = f; i.hasTerms(); i++ )
result += size_maxexp( i.coeff(), maxexp );
return result;
}
}
size_maxexp
int size_maxexp(const CanonicalForm &f, int &maxexp)
Definition cf_ops.cc:641

## sqrt()

CanonicalForm sqrt | ( | const CanonicalForm & | a | ) |

inline

Definition at line 349 of file canonicalform.h.

{ return a.sqrt(); }
CanonicalForm::sqrt
CanonicalForm sqrt() const
CanonicalForm CanonicalForm::sqrt () const.
Definition canonicalform.cc:1383

## swapvar()

CanonicalForm FACTORY_PUBLIC 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.

{
ASSERT( x1.level() > 0 && x2.level() > 0, "cannot swap algebraic Variables" );
if ( f.inCoeffDomain() || x1 == x2 || ( x1 > f.mvar() && x2 > f.mvar() ) )
return f;
else
{
CanonicalForm result = 0;
if ( x1 > x2 )
{
sv_x1 = x2; sv_x2 = x1;
}
else
{
sv_x1 = x1; sv_x2 = x2;
}
if ( f.mvar() < sv_x2 )
// we only have to replace sv_x1 by sv_x2
swapvar_between( f, result, 1, 0 );
else
// we really have to swap variables
swapvar_rec( f, result, 1 );
return result;
}
}
swapvar_rec
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
swapvar_between
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
Variable::level
int level() const
Definition factory.h:143

## tailcoeff() [1/2]

CanonicalForm tailcoeff | ( | const CanonicalForm & | f | ) |

inline

Definition at line 325 of file canonicalform.h.

{ return f.tailcoeff(); }

## tailcoeff() [2/2]

CanonicalForm tailcoeff | ( | const CanonicalForm & | f,
|  | const Variable & | v )

inline

Definition at line 328 of file canonicalform.h.

{ return f.tailcoeff(v); }

## taildegree()

int taildegree | ( | const CanonicalForm & | f | ) |

inline

Definition at line 322 of file canonicalform.h.

{ 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.

{
if ( f.isZero() )
return -1;
else if ( f.inCoeffDomain() )
return 0;
else
{
CFIterator i;
int cdeg = 0, dummy;
// calculate maximum over all coefficients of f, taking
// in account our own exponent
for ( i = f; i.hasTerms(); i++ )
if ( (dummy = totaldegree( i.coeff() ) + i.exp()) > cdeg )
cdeg = dummy;
return cdeg;
}
}
totaldegree
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.

{
if ( f.isZero() )
return -1;
else if ( v1 > v2 )
return 0;
else if ( f.inCoeffDomain() )
return 0;
else if ( f.mvar() < v1 )
return 0;
else if ( f.mvar() == v1 )
return f.degree();
else if ( f.mvar() > v2 )
{
// v2's level is larger than f's level, descend down
CFIterator i;
int cdeg = 0, dummy;
// calculate maximum over all coefficients of f
for ( i = f; i.hasTerms(); i++ )
if ( (dummy = totaldegree( i.coeff(), v1, v2 )) > cdeg )
cdeg = dummy;
return cdeg;
}
else
{
// v1 < f.mvar() <= v2
CFIterator i;
int cdeg = 0, dummy;
// calculate maximum over all coefficients of f, taking
// in account our own exponent
for ( i = f; i.hasTerms(); i++ )
if ( (dummy = totaldegree( i.coeff(), v1, v2 ) + i.exp()) > cdeg )
cdeg = dummy;
return cdeg;
}
}

## vcontent()

CanonicalForm FACTORY_PUBLIC 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 653 of file cf_gcd.cc.

{
ASSERT( x.level() > 0, "cannot calculate vcontent with respect to algebraic variable" );
if ( f.mvar() <= x )
return content( f, x );
else {
CFIterator i;
CanonicalForm d = 0;
for ( i = f; i.hasTerms() && ! d.isOne(); i++ )
d = gcd( d, vcontent( i.coeff(), x ) );
return d;
}
}
vcontent
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ).
Definition cf_gcd.cc:653
CanonicalForm::isOne
CF_NO_INLINE bool isOne() const