My Project
Loading...
Searching...
No Matches
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 "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< 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 FACTORY_PUBLIC CanonicalForm operator- (const CanonicalForm &, const CanonicalForm &)
 
CF_INLINE 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 More...
 
CanonicalForm FACTORY_PUBLIC power (const Variable &v, int n)
 exponentiation More...
 
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 ) More...
 
CanonicalForm FACTORY_PUBLIC lcm (const CanonicalForm &, const CanonicalForm &)
 CanonicalForm lcm ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm FACTORY_PUBLIC pp (const CanonicalForm &)
 CanonicalForm pp ( const CanonicalForm & f ) More...
 
CanonicalForm FACTORY_PUBLIC content (const CanonicalForm &)
 CanonicalForm content ( const CanonicalForm & f ) More...
 
CanonicalForm FACTORY_PUBLIC content (const CanonicalForm &, const Variable &)
 CanonicalForm content ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm FACTORY_PUBLIC icontent (const CanonicalForm &f)
 CanonicalForm icontent ( const CanonicalForm & f ) More...
 
CanonicalForm FACTORY_PUBLIC vcontent (const CanonicalForm &f, const Variable &x)
 CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ) More...
 
CanonicalForm FACTORY_PUBLIC swapvar (const CanonicalForm &, const Variable &, const Variable &)
 swapvar() - swap variables x1 and x2 in f. More...
 
CanonicalForm FACTORY_PUBLIC 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...
 
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 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 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 More...
 
void FACTORY_PUBLIC Off (int)
 switches More...
 
bool FACTORY_PUBLIC isOn (int)
 switches More...
 

Detailed Description

Header for factory's main class CanonicalForm.

Definition in file canonicalform.h.

Macro Definition Documentation

◆ CF_INLINE [1/2]

#define CF_INLINE

Definition at line 54 of file canonicalform.h.

◆ CF_INLINE [2/2]

#define CF_INLINE   inline

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

Definition at line 389 of file canonicalform.h.

◆ CFAFList

Definition at line 390 of file canonicalform.h.

◆ CFAFListIterator

Definition at line 391 of file canonicalform.h.

◆ CFArray

Definition at line 397 of file canonicalform.h.

◆ CFFactor

Definition at line 392 of file canonicalform.h.

◆ CFFList

typedef List<CFFactor> CFFList

Definition at line 393 of file canonicalform.h.

◆ CFFListIterator

Definition at line 394 of file canonicalform.h.

◆ CFList

Definition at line 395 of file canonicalform.h.

◆ CFListIterator

Definition at line 396 of file canonicalform.h.

◆ 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

Definition at line 402 of file canonicalform.h.

◆ ListCFList

Definition at line 399 of file canonicalform.h.

◆ ListCFListIterator

Definition at line 400 of file canonicalform.h.

◆ Varlist

typedef List<Variable> Varlist

Definition at line 403 of file canonicalform.h.

◆ VarlistIterator

Definition at line 404 of file canonicalform.h.

Function Documentation

◆ apply()

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

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

apply() - apply mf to terms of f.

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

An example:

void
diff( CanonicalForm & f, int & i )
{
f = f * i;
if ( i > 0 ) i--;
}
int i
Definition: cfEzgcd.cc:132
FILE * f
Definition: checklibs.c:9
factory's main class
Definition: canonicalform.h:86
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.

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;
416 int exp;
417 Variable x = f.mvar();
418 for ( i = f; i.hasTerms(); i++ )
419 {
420 coeff = i.coeff();
421 exp = i.exp();
422 mf( coeff, exp );
423 if ( ! coeff.isZero() )
424 result += power( x, exp ) * coeff;
425 }
426 return result;
427 }
428}
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Variable x
Definition: cfModGcd.cc:4082
#define ASSERT(expression, message)
Definition: cf_assert.h:99
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
CF_NO_INLINE bool isZero() const
factory's class for variables
Definition: variable.h:33
return result
Definition: facAbsBiFact.cc:75
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357

◆ blcm()

Definition at line 1816 of file canonicalform.cc.

1817{
1818 if ( f.isZero() || g.isZero() )
1819 return CanonicalForm( 0L );
1820/*
1821 else if (f.isOne())
1822 return g;
1823 else if (g.isOne())
1824 return f;
1825*/
1826 else
1827 return (f / bgcd( f, g )) * g;
1828}
CanonicalForm bgcd(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g )
g
Definition: cfModGcd.cc:4090

◆ content() [1/2]

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.

604{
605 if ( f.inPolyDomain() || ( f.inExtension() && ! getReduce( f.mvar() ) ) )
606 {
607 CFIterator i = f;
608 CanonicalForm result = abs( i.coeff() );
609 i++;
610 while ( i.hasTerms() && ! result.isOne() )
611 {
612 result = gcd( i.coeff(), result );
613 i++;
614 }
615 return result;
616 }
617 else
618 return abs( f );
619}
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
CanonicalForm gcd(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:685
bool getReduce(const Variable &alpha)
Definition: variable.cc:232

◆ content() [2/2]

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.

630{
631 if (f.inBaseDomain()) return f;
632 ASSERT( x.level() > 0, "cannot calculate content with respect to algebraic variable" );
633 Variable y = f.mvar();
634
635 if ( y == x )
636 return cf_content( f, 0 );
637 else if ( y < x )
638 return f;
639 else
640 return swapvar( content( swapvar( f, y, x ), y ), y, x );
641}
CanonicalForm FACTORY_PUBLIC 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:578
CanonicalForm content(const CanonicalForm &f)
CanonicalForm content ( const CanonicalForm & f )
Definition: cf_gcd.cc:603
int level() const
Definition: variable.h:49
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.

316{ return f.degree(); }

◆ degree() [2/2]

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

Definition at line 319 of file canonicalform.h.

319{ return f.degree( 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.

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

◆ den()

CanonicalForm den ( const CanonicalForm f)
inline

Definition at line 340 of file canonicalform.h.

340{ return f.den(); }

◆ deriv()

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

Definition at line 346 of file canonicalform.h.

346{ return f.deriv( x ); }

◆ div()

◆ gcd()

Definition at line 685 of file cf_gcd.cc.

686{
687 bool b = f.isZero();
688 if ( b || g.isZero() )
689 {
690 if ( b )
691 return abs( g );
692 else
693 return abs( f );
694 }
695 if ( f.inPolyDomain() || g.inPolyDomain() )
696 {
697 if ( f.mvar() != g.mvar() )
698 {
699 if ( f.mvar() > g.mvar() )
700 return cf_content( f, g );
701 else
702 return cf_content( g, f );
703 }
704 if (isOn(SW_USE_QGCD))
705 {
706 Variable m;
707 if (
708 (getCharacteristic() == 0) &&
710 )
711 {
712 bool on_rational = isOn(SW_RATIONAL);
715 CanonicalForm cdF = bCommonDen( r );
716 if (!on_rational) Off(SW_RATIONAL);
717 return cdF*r;
718 }
719 }
720
721 if ( f.inExtension() && getReduce( f.mvar() ) )
722 return CanonicalForm(1);
723 else
724 {
725 if ( fdivides( f, g ) )
726 return abs( f );
727 else if ( fdivides( g, f ) )
728 return abs( g );
729 if ( !( getCharacteristic() == 0 && isOn( SW_RATIONAL ) ) )
730 {
732 d = gcd_poly( f, g );
733 return abs( d );
734 }
735 else
736 {
737 CanonicalForm cdF = bCommonDen( f );
738 CanonicalForm cdG = bCommonDen( g );
739 CanonicalForm F = f * cdF, G = g * cdG;
740 Off( SW_RATIONAL );
741 CanonicalForm l = gcd_poly( F, G );
742 On( SW_RATIONAL );
743 return abs( l );
744 }
745 }
746 }
747 if ( f.inBaseDomain() && g.inBaseDomain() )
748 return bgcd( f, g );
749 else
750 return 1;
751}
bool isOn(int sw)
switches
void On(int sw)
switches
void Off(int sw)
switches
bool hasFirstAlgVar(const CanonicalForm &f, Variable &a)
check if poly f contains an algebraic variable a
Definition: cf_ops.cc:679
int FACTORY_PUBLIC getCharacteristic()
Definition: cf_char.cc:70
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
CanonicalForm QGCD(const CanonicalForm &F, const CanonicalForm &G)
gcd over Q(a)
Definition: cfGcdAlgExt.cc:730
CanonicalForm b
Definition: cfModGcd.cc:4103
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:43
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:31
CanonicalForm gcd_poly(const CanonicalForm &f, const CanonicalForm &g)
CanonicalForm gcd_poly ( const CanonicalForm & f, const CanonicalForm & g )
Definition: cf_gcd.cc:492
STATIC_VAR TreeM * G
Definition: janet.cc:31

◆ gcd_poly()

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.

493{
494 CanonicalForm fc, gc;
495 bool fc_isUnivariate=f.isUnivariate();
496 bool gc_isUnivariate=g.isUnivariate();
497 bool fc_and_gc_Univariate=fc_isUnivariate && gc_isUnivariate;
498 fc = f;
499 gc = g;
500 int ch=getCharacteristic();
501 if ( ch != 0 )
502 {
503 if (0) {} // dummy, to be able to build without NTL and FLINT
504 #if defined(HAVE_FLINT) && ( __FLINT_RELEASE >= 20503)
505 if ( isOn( SW_USE_FL_GCD_P)
507 #ifdef HAVE_NTL
508 && (ch>10) // if we have NTL: it is better for char <11
509 #endif
510 &&(!hasAlgVar(fc)) && (!hasAlgVar(gc)))
511 {
512 return gcdFlintMP_Zp(fc,gc);
513 }
514 #endif
515 #ifdef HAVE_NTL
516 if ((!fc_and_gc_Univariate) && (isOn( SW_USE_EZGCD_P )))
517 {
518 fc= EZGCD_P (fc, gc);
519 }
520 #endif
521 #if defined(HAVE_NTL) || defined(HAVE_FLINT)
522 else if (isOn(SW_USE_FF_MOD_GCD) && !fc_and_gc_Univariate)
523 {
524 Variable a;
525 if (hasFirstAlgVar (fc, a) || hasFirstAlgVar (gc, a))
526 fc=modGCDFq (fc, gc, a);
528 fc=modGCDGF (fc, gc);
529 else
530 fc=modGCDFp (fc, gc);
531 }
532 #endif
533 else
534 fc = gcd_poly_p( fc, gc );
535 }
536 else if (!fc_and_gc_Univariate) /* && char==0*/
537 {
538 #if defined(HAVE_FLINT) && ( __FLINT_RELEASE >= 20503)
539 if (( isOn( SW_USE_FL_GCD_0) )
540 &&(!hasAlgVar(fc)) && (!hasAlgVar(gc)))
541 {
542 return gcdFlintMP_QQ(fc,gc);
543 }
544 else
545 #endif
546 #ifdef HAVE_NTL
547 if ( isOn( SW_USE_EZGCD ) )
548 fc= ezgcd (fc, gc);
549 else
550 #endif
551 #if defined(HAVE_NTL) || defined(HAVE_FLINT)
553 fc = modGCDZ( fc, gc);
554 else
555 #endif
556 {
557 fc = gcd_poly_0( fc, gc );
558 }
559 }
560 else
561 {
562 fc = gcd_poly_0( fc, gc );
563 }
564 if ((ch>0)&&(!hasAlgVar(fc))) fc/=fc.lc();
565 return fc;
566}
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
static CanonicalForm ezgcd(const CanonicalForm &FF, const CanonicalForm &GG, REvaluation &b, bool internal)
real implementation of EZGCD over Z
Definition: cfEzgcd.cc:498
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:478
CanonicalForm modGCDFp(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &coF, CanonicalForm &coG, bool &topLevel, CFList &l)
Definition: cfModGcd.cc:1223
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:872
CanonicalForm modGCDZ(const CanonicalForm &FF, const CanonicalForm &GG)
modular GCD over Z
static const int SW_USE_CHINREM_GCD
set to 1 to use modular gcd over Z
Definition: cf_defs.h:41
static const int SW_USE_FL_GCD_P
set to 1 to use Flints gcd over F_p
Definition: cf_defs.h:47
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:37
static const int SW_USE_FF_MOD_GCD
set to 1 to use modular GCD over F_q
Definition: cf_defs.h:45
static const int SW_USE_EZGCD
set to 1 to use EZGCD over Z
Definition: cf_defs.h:35
static const int SW_USE_FL_GCD_0
set to 1 to use Flints gcd over Q/Z
Definition: cf_defs.h:49
#define GaloisFieldDomain
Definition: cf_defs.h:18
static CanonicalForm gcd_poly_0(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:417
static CanonicalForm gcd_poly_p(const CanonicalForm &f, const CanonicalForm &g)
Definition: cf_gcd.cc:264
static int gettype()
Definition: cf_factory.h:28
CanonicalForm lc() const
CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const.
int hasAlgVar(const CanonicalForm &f, const Variable &v)

◆ getCharacteristic()

int FACTORY_PUBLIC getCharacteristic ( )

Definition at line 70 of file cf_char.cc.

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

◆ getGFDegree()

int getGFDegree ( )

Definition at line 75 of file cf_char.cc.

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

◆ getGFGenerator()

CanonicalForm getGFGenerator ( )

Definition at line 81 of file cf_char.cc.

82{
83 ASSERT( theDegree > 1, "not in GF(q)" );
84 return int2imm_gf( 1 );
85}
InternalCF * int2imm_gf(long i)
Definition: imm.h:106

◆ getNumVars()

int getNumVars ( const CanonicalForm f)

int getNumVars ( const CanonicalForm & f )

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

Definition at line 314 of file cf_ops.cc.

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

◆ getVars()

CanonicalForm getVars ( const CanonicalForm f)

CanonicalForm getVars ( const CanonicalForm & f )

getVars() - get polynomial variables of f.

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

Definition at line 350 of file cf_ops.cc.

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

◆ hasFirstAlgVar()

bool hasFirstAlgVar ( const CanonicalForm f,
Variable a 
)

check if poly f contains an algebraic variable a

Definition at line 679 of file cf_ops.cc.

680{
681 if( f.inBaseDomain() ) // f has NO alg. variable
682 return false;
683 if( f.level()<0 ) // f has only alg. vars, so take the first one
684 {
685 a = f.mvar();
686 return true;
687 }
688 for(CFIterator i=f; i.hasTerms(); i++)
689 if( hasFirstAlgVar( i.coeff(), a ))
690 return true; // 'a' is already set
691 return false;
692}
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.

361{
362 if ( f.level() > 0 )
363 return power( f.mvar(), f.degree() ) * f.LC();
364 else
365 return f;
366}
CanonicalForm FACTORY_PUBLIC power(const CanonicalForm &f, int n)
exponentiation

◆ headdegree()

int headdegree ( const CanonicalForm f)
inline

Definition at line 369 of file canonicalform.h.

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

◆ icontent()

CanonicalForm icontent ( const CanonicalForm & f )

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

Definition at line 74 of file cf_gcd.cc.

75{
76 return icontent( f, 0 );
77}
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.

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

◆ is_imm()

int is_imm ( const InternalCF *const  ptr)
inline

Definition at line 65 of file canonicalform.h.

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

◆ isOn()

bool FACTORY_PUBLIC isOn ( int  sw)

switches

Definition at line 1971 of file canonicalform.cc.

1972{
1973 return cf_glob_switches.isOn( sw );
1974}
INST_VAR CFSwitches cf_glob_switches
Definition: cf_switches.cc:54
bool isOn(int s) const
check if 's' is on
Definition: cf_switches.h:55

◆ lc()

CanonicalForm lc ( const CanonicalForm f)
inline

Definition at line 304 of file canonicalform.h.

304{ return f.lc(); }

◆ Lc()

CanonicalForm Lc ( const CanonicalForm f)
inline

Definition at line 307 of file canonicalform.h.

307{ return f.Lc(); }

◆ LC() [1/2]

CanonicalForm LC ( const CanonicalForm f)
inline

Definition at line 310 of file canonicalform.h.

310{ return f.LC(); }

◆ LC() [2/2]

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

Definition at line 313 of file canonicalform.h.

313{ return f.LC( v ); }

◆ lcm()

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

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

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

Returns zero if one of f or g equals zero.

Definition at line 763 of file cf_gcd.cc.

764{
765 if ( f.isZero() || g.isZero() )
766 return 0;
767 else
768 return ( f / gcd( f, g ) ) * g;
769}

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

698{
699 ASSERT (n >= 0, "cannot left shift by negative number");
700 if (F.inBaseDomain())
701 return F;
702 if (n == 0)
703 return F;
704 Variable x=F.mvar();
706 for (CFIterator i= F; i.hasTerms(); i++)
707 result += i.coeff()*power (x, i.exp()*n);
708 return result;
709}
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
bool inBaseDomain() const

◆ level()

int level ( const CanonicalForm f)
inline

Definition at line 331 of file canonicalform.h.

331{ return f.level(); }

◆ mapdomain()

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

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

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

Definition at line 440 of file cf_ops.cc.

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

◆ mapinto()

CanonicalForm mapinto ( const CanonicalForm f)
inline

Definition at line 355 of file canonicalform.h.

355{ return f.mapinto(); }

◆ mod()

◆ mvar()

Variable mvar ( const CanonicalForm f)
inline

Definition at line 334 of file canonicalform.h.

334{ return f.mvar(); }

◆ num()

CanonicalForm num ( const CanonicalForm f)
inline

Definition at line 337 of file canonicalform.h.

337{ return f.num(); }

◆ Off()

void FACTORY_PUBLIC Off ( int  sw)

switches

Definition at line 1964 of file canonicalform.cc.

1965{
1966 cf_glob_switches.Off( sw );
1967}
void Off(int s)
switch 's' off
Definition: cf_switches.h:53

◆ On()

void FACTORY_PUBLIC On ( int  sw)

switches

Definition at line 1957 of file canonicalform.cc.

1958{
1959 cf_glob_switches.On( sw );
1960}
void On(int s)
switch 's' on
Definition: cf_switches.h:51

◆ operator%()

◆ operator*()

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

Definition at line 524 of file cf_inline.cc.

525{
526 CanonicalForm result( lhs );
527 result *= rhs;
528 return result;
529}

◆ operator+()

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

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

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

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

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

Type info:

lhs, rhs: CurrentPP

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

Developers note:

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

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

See also
CanonicalForm::operator +=()

Definition at line 503 of file cf_inline.cc.

504{
505 CanonicalForm result( lhs );
506 result += rhs;
507 return result;
508}

◆ operator-()

◆ operator/()

◆ power() [1/2]

CanonicalForm FACTORY_PUBLIC power ( const CanonicalForm f,
int  n 
)

exponentiation

Definition at line 1896 of file canonicalform.cc.

1897{
1898 ASSERT( n >= 0, "illegal exponent" );
1899 if ( f.isZero() )
1900 return CanonicalForm(0L);
1901 else if ( f.isOne() )
1902 return f;
1903 else if ( f == -1 )
1904 {
1905 if ( n % 2 == 0 )
1906 return CanonicalForm(1L);
1907 else
1908 return CanonicalForm(-1L);
1909 }
1910 else if ( n == 0 )
1911 return CanonicalForm(1L);
1912
1913 //else if (f.inGF())
1914 //{
1915 //}
1916 else
1917 {
1919 h=f;
1920 while(n%2==0)
1921 {
1922 h*=h;
1923 n/=2;
1924 }
1925 g=h;
1926 while(1)
1927 {
1928 n/=2;
1929 if(n==0)
1930 return g;
1931 h*=h;
1932 if(n%2!=0) g*=h;
1933 }
1934 }
1935}
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.

1940{
1941 //ASSERT( n >= 0, "illegal exponent" );
1942 if ( n == 0 )
1943 return 1;
1944 else if ( n == 1 )
1945 return v;
1946 else if (( v.level() < 0 ) && (hasMipo(v)))
1947 {
1948 CanonicalForm result( v, n-1 );
1949 return result * v;
1950 }
1951 else
1952 return CanonicalForm( v, n );
1953}
bool hasMipo(const Variable &alpha)
Definition: variable.cc:226

◆ pp()

CanonicalForm pp ( const CanonicalForm & f )

pp() - return primitive part of f.

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

Definition at line 676 of file cf_gcd.cc.

677{
678 if ( f.isZero() )
679 return f;
680 else
681 return f / content( f );
682}

◆ reduce()

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.

661{
662 if(f.inBaseDomain() || f.level() < M.level())
663 return f;
664 if(f.level() == M.level())
665 {
666 if(f.degree() < M.degree())
667 return f;
668 CanonicalForm tmp = mod (f, M);
669 return tmp;
670 }
671 // here: f.level() > M.level()
673 for(CFIterator i=f; i.hasTerms(); i++)
674 result += reduce(i.coeff(),M) * power(f.mvar(),i.exp());
675 return result;
676}
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
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
#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.

272{
273 //ASSERT( x2.level() > 0, "cannot replace with algebraic variable" );
274 if ( f.inBaseDomain() || x1 == x2 || ( x1 > f.mvar() ) )
275 return f;
276 else
277 {
278 sv_x1 = x1;
279 sv_x2 = x2;
280 return replacevar_between( f );
281 }
282}
STATIC_INST_VAR 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
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.

29{
30 if ( c == 0 )
31 {
32 theDegree = 0;
35 }
36 else
37 {
38 theDegree = 1;
41 if (c!=theCharacteristic)
42 {
43 if (c > 536870909) factoryError("characteristic is too large(max is 2^29)");
44 ff_setprime( c );
45 }
47 }
48}
#define FiniteFieldDomain
Definition: cf_defs.h:19
#define IntegerDomain
Definition: cf_defs.h:21
int cf_getNumSmallPrimes()
Definition: cf_primes.cc:34
int cf_getSmallPrime(int i)
Definition: cf_primes.cc:28
VAR void(* factoryError)(const char *s)
Definition: cf_util.cc:80
static void settype(int type)
Definition: cf_factory.h:29
VAR bool ff_big
Definition: ffops.cc:16
void ff_setprime(const int p)
Definition: ffops.cc:19

◆ setCharacteristic() [2/3]

void setCharacteristic ( int  c,
int  n 
)

◆ setCharacteristic() [3/3]

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

Definition at line 61 of file cf_char.cc.

62{
63 ASSERT( c != 0 && n > 1, "illegal GF(q)" );
66 theDegree = n;
68}
void setCharacteristic(int c)
Definition: cf_char.cc:28
void gf_setcharacteristic(int p, int n, char name)
Definition: gfops.cc:202
int name
New type name for int.
Definition: templateForC.h:21

◆ sign()

int sign ( const CanonicalForm a)
inline

Definition at line 343 of file canonicalform.h.

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

◆ size() [1/2]

int size ( const CanonicalForm f)

int size ( const CanonicalForm & f )

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

Returns one if f is in an coefficient domain.

Definition at line 627 of file cf_ops.cc.

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

◆ size() [2/2]

int size ( const CanonicalForm f,
const Variable v 
)

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

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

Returns one if f is in an base domain.

Definition at line 600 of file cf_ops.cc.

601{
602 if ( f.inBaseDomain() )
603 return 1;
604
605 if ( f.mvar() < v )
606 // polynomials with level < v1 are counted as coefficients
607 return 1;
608 else
609 {
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}

◆ size_maxexp()

int size_maxexp ( const CanonicalForm f,
int &  maxexp 
)

Definition at line 641 of file cf_ops.cc.

642{
643 if ( f.inCoeffDomain() )
644 return 1;
645 else
646 {
647 if (f.degree()>maxexp) maxexp=f.degree();
648 int result = 0;
650 for ( i = f; i.hasTerms(); i++ )
651 result += size_maxexp( i.coeff(), maxexp );
652 return result;
653 }
654}
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.

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

◆ swapvar()

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 {
176 if ( x1 > x2 )
177 {
178 sv_x1 = x2; sv_x2 = x1;
179 }
180 else
181 {
182 sv_x1 = x1; sv_x2 = x2;
183 }
184 if ( f.mvar() < sv_x2 )
185 // we only have to replace sv_x1 by sv_x2
186 swapvar_between( f, result, 1, 0 );
187 else
188 // we really have to swap variables
189 swapvar_rec( f, result, 1 );
190 return result;
191 }
192}
static void swapvar_rec(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term)
swapvar_between() - swap occurences of sv_x1 and sv_x2 in f.
Definition: cf_ops.cc:113
static void swapvar_between(const CanonicalForm &f, CanonicalForm &result, const CanonicalForm &term, int expx2)
static void swapvar_between ( const CanonicalForm & f, CanonicalForm & result, const CanonicalForm & ...
Definition: cf_ops.cc:58

◆ tailcoeff() [1/2]

CanonicalForm tailcoeff ( const CanonicalForm f)
inline

Definition at line 325 of file canonicalform.h.

325{ return f.tailcoeff(); }

◆ tailcoeff() [2/2]

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

Definition at line 328 of file canonicalform.h.

328{ return f.tailcoeff(v); }

◆ taildegree()

int taildegree ( const CanonicalForm f)
inline

Definition at line 322 of file canonicalform.h.

322{ return f.taildegree(); }

◆ totaldegree() [1/2]

int totaldegree ( const CanonicalForm f)

int totaldegree ( const CanonicalForm & f )

totaldegree() - return the total degree of f.

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

Definition at line 523 of file cf_ops.cc.

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

◆ totaldegree() [2/2]

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

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

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

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

Definition at line 554 of file cf_ops.cc.

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

◆ vcontent()

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

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.

654{
655 ASSERT( x.level() > 0, "cannot calculate vcontent with respect to algebraic variable" );
656
657 if ( f.mvar() <= x )
658 return content( f, x );
659 else {
661 CanonicalForm d = 0;
662 for ( i = f; i.hasTerms() && ! d.isOne(); i++ )
663 d = gcd( d, vcontent( i.coeff(), x ) );
664 return d;
665 }
666}
CanonicalForm vcontent(const CanonicalForm &f, const Variable &x)
CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x )
Definition: cf_gcd.cc:653
CF_NO_INLINE bool isOne() const