My Project  UNKNOWN_GIT_VERSION
Public Member Functions | Private Attributes | Friends
CanonicalForm Class Reference

factory's main class More...

#include <canonicalform.h>

Public Member Functions

CF_INLINE CanonicalForm ()
 CF_INLINE CanonicalForm::CanonicalForm () More...
 
CF_INLINE CanonicalForm (const CanonicalForm &)
 CF_INLINE CanonicalForm::CanonicalForm ( const CanonicalForm & cf ) More...
 
CF_INLINE CanonicalForm (InternalCF *)
 CF_INLINE CanonicalForm::CanonicalForm ( InternalCF * cf ) More...
 
CF_INLINE CanonicalForm (const int)
 CF_INLINE CanonicalForm::CanonicalForm ( const int i ) More...
 
CF_INLINE CanonicalForm (const long)
 
CF_INLINE CanonicalForm (const Variable &)
 CF_INLINE CanonicalForm::CanonicalForm ( const Variable & v ) More...
 
CF_INLINE CanonicalForm (const Variable &, int)
 CF_INLINE CanonicalForm::CanonicalForm ( const Variable & v, int e ) More...
 
 CanonicalForm (const char *, const int base=10)
 constructors, destructors, selectors More...
 
CF_NO_INLINE ~CanonicalForm ()
 CF_INLINE CanonicalForm::~CanonicalForm () More...
 
InternalCFgetval () const
 
CanonicalForm deepCopy () const
 
void mpzval (mpz_t val) const
 
CF_NO_INLINE bool isOne () const
 CF_INLINE bool CanonicalForm::isOne, isZero () const. More...
 
CF_NO_INLINE bool isZero () const
 
bool isImm () const
 
bool inZ () const
 predicates More...
 
bool inQ () const
 
bool inFF () const
 
bool inGF () const
 
bool inBaseDomain () const
 
bool inExtension () const
 
bool inCoeffDomain () const
 
bool inPolyDomain () const
 
bool inQuotDomain () const
 
bool isFFinGF () const
 
bool isUnivariate () const
 
bool isHomogeneous () const
 
long intval () const
 conversion functions More...
 
CanonicalForm mapinto () const
 
CanonicalForm lc () const
 CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const. More...
 
CanonicalForm Lc () const
 
CanonicalForm LC () const
 
CanonicalForm LC (const Variable &v) const
 
int degree () const
 Returns -1 for the zero polynomial and 0 if CO is in a base domain. More...
 
int degree (const Variable &v) const
 returns -1 for the zero polynomial and 0 if CO is in a base domain. More...
 
CanonicalForm tailcoeff () const
 tailcoeff() - return least coefficient More...
 
CanonicalForm tailcoeff (const Variable &v) const
 tailcoeff( v ) returns the tail coefficient of CO where CO is considered an univariate polynomial in the polynomial variable v. More...
 
int taildegree () const
 taildegree() returns -1 for the zero polynomial, 0 if CO is in a base domain, otherwise the least degree of CO where CO is considered a univariate polynomial in its main variable. More...
 
int level () const
 level() returns the level of CO. More...
 
Variable mvar () const
 mvar() returns the main variable of CO or Variable() if CO is in a base domain. More...
 
CanonicalForm num () const
 num() returns the numerator of CO if CO is a rational number, CO itself otherwise. More...
 
CanonicalForm den () const
 den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!) otherwise. More...
 
CF_NO_INLINE CanonicalFormoperator= (const CanonicalForm &)
 CF_INLINE CanonicalForm & CanonicalForm::operator = ( const CanonicalForm & cf ) More...
 
CF_NO_INLINE CanonicalFormoperator= (const long)
 operator =() - assign long ‘cf’ to CO. More...
 
CanonicalFormoperator+= (const CanonicalForm &)
 assignment operators More...
 
CanonicalFormoperator-= (const CanonicalForm &)
 
CanonicalFormoperator*= (const CanonicalForm &)
 
CanonicalFormoperator/= (const CanonicalForm &)
 
CanonicalFormoperator%= (const CanonicalForm &)
 
CanonicalFormdiv (const CanonicalForm &)
 
CanonicalFormtryDiv (const CanonicalForm &, const CanonicalForm &, bool &)
 same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible More...
 
CanonicalFormmod (const CanonicalForm &)
 
CanonicalForm operator() (const CanonicalForm &f) const
 operator ()() - evaluation operator. More...
 
CanonicalForm operator() (const CanonicalForm &f, const Variable &v) const
 Returns CO if CO is in a base domain. More...
 
CanonicalForm operator[] (int i) const
 operator []() - return i'th coefficient from CO. More...
 
CanonicalForm deriv () const
 deriv() - return the formal derivation of CO. More...
 
CanonicalForm deriv (const Variable &x) const
 deriv( x ) derives CO with respect to x. More...
 
int sign () const
 int CanonicalForm::sign () const More...
 
CanonicalForm sqrt () const
 CanonicalForm CanonicalForm::sqrt () const. More...
 
int ilog2 () const
 int CanonicalForm::ilog2 () const More...
 
void print (OSTREAM &, char *) const
 input/output More...
 
void print (OSTREAM &) const
 
CanonicalForm genZero () const
 genOne(), genZero() More...
 
CanonicalForm genOne () const
 
CF_INLINE CanonicalForm ()
 
CF_INLINE CanonicalForm (const CanonicalForm &)
 
CF_INLINE CanonicalForm (InternalCF *)
 
CF_INLINE CanonicalForm (const int)
 
CF_INLINE CanonicalForm (const long)
 
CF_INLINE CanonicalForm (const Variable &)
 
CF_INLINE CanonicalForm (const Variable &, int)
 
 CanonicalForm (const char *, const int base=10)
 
CF_NO_INLINE ~CanonicalForm ()
 
InternalCFgetval () const
 
CanonicalForm deepCopy () const
 
void mpzval (mpz_t val) const
 
CF_NO_INLINE bool isOne () const
 
CF_NO_INLINE bool isZero () const
 
bool isImm () const
 
bool inZ () const
 
bool inQ () const
 
bool inFF () const
 
bool inGF () const
 
bool inBaseDomain () const
 
bool inExtension () const
 
bool inCoeffDomain () const
 
bool inPolyDomain () const
 
bool inQuotDomain () const
 
bool isFFinGF () const
 
bool isUnivariate () const
 
bool isHomogeneous () const
 
long intval () const
 
CanonicalForm mapinto () const
 
CanonicalForm lc () const
 
CanonicalForm Lc () const
 
CanonicalForm LC () const
 
CanonicalForm LC (const Variable &v) const
 
int degree () const
 
int degree (const Variable &v) const
 
CanonicalForm tailcoeff () const
 
CanonicalForm tailcoeff (const Variable &v) const
 
int taildegree () const
 
int level () const
 
Variable mvar () const
 
CanonicalForm num () const
 
CanonicalForm den () const
 
CF_NO_INLINE CanonicalFormoperator= (const CanonicalForm &)
 
CF_NO_INLINE CanonicalFormoperator= (const long)
 
CanonicalFormoperator+= (const CanonicalForm &)
 
CanonicalFormoperator-= (const CanonicalForm &)
 
CanonicalFormoperator*= (const CanonicalForm &)
 
CanonicalFormoperator/= (const CanonicalForm &)
 
CanonicalFormoperator%= (const CanonicalForm &)
 
CanonicalFormdiv (const CanonicalForm &)
 
CanonicalFormtryDiv (const CanonicalForm &, const CanonicalForm &, bool &)
 
CanonicalFormmod (const CanonicalForm &)
 
CanonicalForm operator() (const CanonicalForm &f) const
 
CanonicalForm operator() (const CanonicalForm &f, const Variable &v) const
 
CanonicalForm operator[] (int i) const
 
CanonicalForm deriv () const
 
CanonicalForm deriv (const Variable &x) const
 
int sign () const
 
CanonicalForm sqrt () const
 
int ilog2 () const
 
void print (OSTREAM &, char *) const
 
void print (OSTREAM &) const
 
CanonicalForm genZero () const
 
CanonicalForm genOne () const
 
CF_INLINE CanonicalForm ()
 
CF_INLINE CanonicalForm (const CanonicalForm &)
 
CF_INLINE CanonicalForm (InternalCF *)
 
CF_INLINE CanonicalForm (const int)
 
CF_INLINE CanonicalForm (const long)
 
CF_INLINE CanonicalForm (const Variable &)
 
CF_INLINE CanonicalForm (const Variable &, int)
 
 CanonicalForm (const char *, const int base=10)
 
CF_NO_INLINE ~CanonicalForm ()
 
InternalCFgetval () const
 
CanonicalForm deepCopy () const
 
void mpzval (mpz_t val) const
 
CF_NO_INLINE bool isOne () const
 
CF_NO_INLINE bool isZero () const
 
bool isImm () const
 
bool inZ () const
 
bool inQ () const
 
bool inFF () const
 
bool inGF () const
 
bool inBaseDomain () const
 
bool inExtension () const
 
bool inCoeffDomain () const
 
bool inPolyDomain () const
 
bool inQuotDomain () const
 
bool isFFinGF () const
 
bool isUnivariate () const
 
bool isHomogeneous () const
 
long intval () const
 
CanonicalForm mapinto () const
 
CanonicalForm lc () const
 
CanonicalForm Lc () const
 
CanonicalForm LC () const
 
CanonicalForm LC (const Variable &v) const
 
int degree () const
 
int degree (const Variable &v) const
 
CanonicalForm tailcoeff () const
 
CanonicalForm tailcoeff (const Variable &v) const
 
int taildegree () const
 
int level () const
 
Variable mvar () const
 
CanonicalForm num () const
 
CanonicalForm den () const
 
CF_NO_INLINE CanonicalFormoperator= (const CanonicalForm &)
 
CF_NO_INLINE CanonicalFormoperator= (const long)
 
CanonicalFormoperator+= (const CanonicalForm &)
 
CanonicalFormoperator-= (const CanonicalForm &)
 
CanonicalFormoperator*= (const CanonicalForm &)
 
CanonicalFormoperator/= (const CanonicalForm &)
 
CanonicalFormoperator%= (const CanonicalForm &)
 
CanonicalFormdiv (const CanonicalForm &)
 
CanonicalFormtryDiv (const CanonicalForm &, const CanonicalForm &, bool &)
 
CanonicalFormmod (const CanonicalForm &)
 
CanonicalForm operator() (const CanonicalForm &f) const
 
CanonicalForm operator() (const CanonicalForm &f, const Variable &v) const
 
CanonicalForm operator[] (int i) const
 
CanonicalForm deriv () const
 
CanonicalForm deriv (const Variable &x) const
 
int sign () const
 
CanonicalForm sqrt () const
 
int ilog2 () const
 
void print (OSTREAM &, char *) const
 
void print (OSTREAM &) const
 
CanonicalForm genZero () const
 
CanonicalForm genOne () const
 
- Public Member Functions inherited from omallocClass
void * operator new (size_t size) throw (std::bad_alloc)
 
void operator delete (void *block) throw ()
 
void * operator new[] (size_t size) throw (std::bad_alloc)
 
void operator delete[] (void *block) throw ()
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 
void * operator new[] (size_t size, const std::nothrow_t &) throw ()
 

Private Attributes

InternalCFvalue
 

Friends

class CFIterator
 
bool operator== (const CanonicalForm &, const CanonicalForm &)
 operator ==() - compare canonical forms on (in)equality. More...
 
bool operator!= (const CanonicalForm &, const CanonicalForm &)
 operator !=() returns true iff lhs does not equal rhs. More...
 
bool operator> (const CanonicalForm &, const CanonicalForm &)
 operator >() - compare canonical forms. More...
 
bool operator< (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm operator- (const CanonicalForm &)
 CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf ) More...
 
void divrem (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool divremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool tryDivremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &, const CanonicalForm &, bool &)
 same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible More...
 
CanonicalForm bgcd (const CanonicalForm &, const CanonicalForm &)
 CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm bextgcd (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b ) More...
 
OSTREAMoperator<< (OSTREAM &, const CanonicalForm &)
 
ISTREAMoperator>> (ISTREAM &, CanonicalForm &)
 
bool operator== (const CanonicalForm &, const CanonicalForm &)
 operator ==() - compare canonical forms on (in)equality. More...
 
bool operator!= (const CanonicalForm &, const CanonicalForm &)
 operator !=() returns true iff lhs does not equal rhs. More...
 
bool operator> (const CanonicalForm &, const CanonicalForm &)
 operator >() - compare canonical forms. More...
 
bool operator< (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm operator- (const CanonicalForm &)
 CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf ) More...
 
void divrem (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool divremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool tryDivremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &, const CanonicalForm &, bool &)
 same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible More...
 
CanonicalForm bgcd (const CanonicalForm &, const CanonicalForm &)
 CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm bextgcd (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b ) More...
 
OSTREAMoperator<< (OSTREAM &, const CanonicalForm &)
 
ISTREAMoperator>> (ISTREAM &, CanonicalForm &)
 
bool operator== (const CanonicalForm &, const CanonicalForm &)
 operator ==() - compare canonical forms on (in)equality. More...
 
bool operator!= (const CanonicalForm &, const CanonicalForm &)
 operator !=() returns true iff lhs does not equal rhs. More...
 
bool operator> (const CanonicalForm &, const CanonicalForm &)
 operator >() - compare canonical forms. More...
 
bool operator< (const CanonicalForm &, const CanonicalForm &)
 
CF_NO_INLINE CanonicalForm operator- (const CanonicalForm &)
 CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf ) More...
 
void divrem (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool divremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 
bool tryDivremt (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &, const CanonicalForm &, bool &)
 same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible More...
 
CanonicalForm bgcd (const CanonicalForm &, const CanonicalForm &)
 CanonicalForm bgcd ( const CanonicalForm & f, const CanonicalForm & g ) More...
 
CanonicalForm bextgcd (const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm &)
 CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b ) More...
 
OSTREAMoperator<< (OSTREAM &, const CanonicalForm &)
 
ISTREAMoperator>> (ISTREAM &, CanonicalForm &)
 

Detailed Description

factory's main class

a CanonicalForm can represent a polynomial over or a constant in F_p, F_p(alpha), GF (F_p[t]/(Conway polynomial)), Z, or Q

See also
int_poly.h, variable.h, ffops.h, gfops.h, imm.h, int_int.h, int_rat.h

Definition at line 77 of file canonicalform.h.

Constructor & Destructor Documentation

◆ CanonicalForm() [1/24]

CF_INLINE CanonicalForm::CanonicalForm ( )

CF_INLINE CanonicalForm::CanonicalForm ()

CanonicalForm() - create the default canonical form.

The canonical form is initialized to zero from the current domain.

Definition at line 126 of file cf_inline.cc.

127  : value( CFFactory::basic( 0L ) )
128 {
129 }

◆ CanonicalForm() [2/24]

CF_INLINE CanonicalForm::CanonicalForm ( const CanonicalForm cf)

CF_INLINE CanonicalForm::CanonicalForm ( const CanonicalForm & cf )

CanonicalForm() - create a copy of a canonical form.

Type info:

cf: Anything

Definition at line 166 of file cf_inline.cc.

167  : value( is_imm( cf.value ) ? cf.value : cf.value->copyObject() )
168 {
169 }

◆ CanonicalForm() [3/24]

CF_INLINE CanonicalForm::CanonicalForm ( InternalCF cf)

CF_INLINE CanonicalForm::CanonicalForm ( InternalCF * cf )

CanonicalForm() - create a canonical form from a pointer to an internal canonical form.

This constructor is reserved for internal usage.

Developers note:

The canonical form gets its value immediately from ‘cf’. `cf's reference counter is not incremented, so be careful with this constructor.

Definition at line 187 of file cf_inline.cc.

188  : value( cf )
189 {
190 }

◆ CanonicalForm() [4/24]

CF_INLINE CanonicalForm::CanonicalForm ( const int  i)

CF_INLINE CanonicalForm::CanonicalForm ( const int i )

CanonicalForm() - create a canonical form from an integer.

The canonical form is initialized to the "canonical image" of ‘i’ in the current domain. This is ‘i’ itself for characteristic zero, ‘i’ mod p for finite fields of characteristic p, and ‘i’ mod p^n for prime power domains with p^n elements.

Definition at line 144 of file cf_inline.cc.

145  : value( CFFactory::basic( (const long)i ) )
146 {
147 }

◆ CanonicalForm() [5/24]

CF_INLINE CanonicalForm::CanonicalForm ( const long  i)

Definition at line 150 of file cf_inline.cc.

151  : value( CFFactory::basic( i ) )
152 {
153 }

◆ CanonicalForm() [6/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable v)

CF_INLINE CanonicalForm::CanonicalForm ( const Variable & v )

CanonicalForm() - create a canonical form from a variable.

If ‘v’ is a polynomial variable or an algebraic element the resulting polynomial (or algebraic element) is 1*‘v’^1, the one being from the current domain.

Variables of level ‘LEVELBASE’ are transformed to one from the current domain.

Type info:

v: Anything

Definition at line 210 of file cf_inline.cc.

211  : value( CFFactory::poly( v ) )
212 {
213 }

◆ CanonicalForm() [7/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable v,
int  e 
)

CF_INLINE CanonicalForm::CanonicalForm ( const Variable & v, int e )

CanonicalForm() - create a canonical form from a power of a variable.

If ‘v’ is a polynomial variable or an algebraic element the resulting polynomial (or algebraic element) is 1*‘v’^‘e’, the one being from the current domain. Algebraic elements are reduced modulo their minimal polynomial.

Variables of level ‘LEVELBASE’ are transformed to one from the current domain.

Type info:

v: Anything

Definition at line 235 of file cf_inline.cc.

236  : value( CFFactory::poly( v, e ) )
237 {
238  //ASSERT( e > 0, "math error: exponent has to be positive" );
239 }

◆ CanonicalForm() [8/24]

CanonicalForm::CanonicalForm ( const char *  str,
const int  base = 10 
)

constructors, destructors, selectors

Definition at line 26 of file canonicalform.cc.

26  : value( CFFactory::basic( str, base ) )
27 {
28 }

◆ ~CanonicalForm() [1/3]

CF_INLINE CanonicalForm::~CanonicalForm ( )

CF_INLINE CanonicalForm::~CanonicalForm ()

~CanonicalForm() - delete CO.

Type info:

CO: Anything

Definition at line 253 of file cf_inline.cc.

254 {
255  if ( (! is_imm( value )) && value->deleteObject() )
256  delete value;
257 }

◆ CanonicalForm() [9/24]

CF_INLINE CanonicalForm::CanonicalForm ( )

◆ CanonicalForm() [10/24]

CF_INLINE CanonicalForm::CanonicalForm ( const CanonicalForm )

◆ CanonicalForm() [11/24]

CF_INLINE CanonicalForm::CanonicalForm ( InternalCF )

◆ CanonicalForm() [12/24]

CF_INLINE CanonicalForm::CanonicalForm ( const int  )

◆ CanonicalForm() [13/24]

CF_INLINE CanonicalForm::CanonicalForm ( const long  )

◆ CanonicalForm() [14/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable )

◆ CanonicalForm() [15/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable ,
int   
)

◆ CanonicalForm() [16/24]

CanonicalForm::CanonicalForm ( const char *  ,
const int  base = 10 
)

◆ ~CanonicalForm() [2/3]

CF_NO_INLINE CanonicalForm::~CanonicalForm ( )

◆ CanonicalForm() [17/24]

CF_INLINE CanonicalForm::CanonicalForm ( )

◆ CanonicalForm() [18/24]

CF_INLINE CanonicalForm::CanonicalForm ( const CanonicalForm )

◆ CanonicalForm() [19/24]

CF_INLINE CanonicalForm::CanonicalForm ( InternalCF )

◆ CanonicalForm() [20/24]

CF_INLINE CanonicalForm::CanonicalForm ( const int  )

◆ CanonicalForm() [21/24]

CF_INLINE CanonicalForm::CanonicalForm ( const long  )

◆ CanonicalForm() [22/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable )

◆ CanonicalForm() [23/24]

CF_INLINE CanonicalForm::CanonicalForm ( const Variable ,
int   
)

◆ CanonicalForm() [24/24]

CanonicalForm::CanonicalForm ( const char *  ,
const int  base = 10 
)

◆ ~CanonicalForm() [3/3]

CF_NO_INLINE CanonicalForm::~CanonicalForm ( )

Member Function Documentation

◆ deepCopy() [1/3]

CanonicalForm CanonicalForm::deepCopy ( ) const

Definition at line 40 of file canonicalform.cc.

41 {
42  if ( is_imm( value ) )
43  return *this;
44  else
45  return CanonicalForm( value->deepCopyObject() );
46 }

◆ deepCopy() [2/3]

CanonicalForm CanonicalForm::deepCopy ( ) const

◆ deepCopy() [3/3]

CanonicalForm CanonicalForm::deepCopy ( ) const

◆ degree() [1/6]

int CanonicalForm::degree ( ) const

Returns -1 for the zero polynomial and 0 if CO is in a base domain.

degree() returns the degree of CO in its main variable. Elements in an algebraic extension are considered polynomials.

See also
InternalCF::degree(), InternalPoly::degree(), degree(), ::degree( v )

Definition at line 381 of file canonicalform.cc.

382 {
383  int what = is_imm( value );
384  if ( what )
385  if ( what == FFMARK )
386  return imm_iszero_p( value ) ? -1 : 0;
387  else if ( what == INTMARK )
388  return imm_iszero( value ) ? -1 : 0;
389  else
390  return imm_iszero_gf( value ) ? -1 : 0;
391  else
392  return value->degree();
393 }

◆ degree() [2/6]

int CanonicalForm::degree ( ) const

◆ degree() [3/6]

int CanonicalForm::degree ( ) const

◆ degree() [4/6]

int CanonicalForm::degree ( const Variable v) const

returns -1 for the zero polynomial and 0 if CO is in a base domain.

degree( v ) returns the degree of CO with respect to v. Elements in an algebraic extension are considered polynomials, and v may be algebraic.

See also
InternalCF::degree(), InternalPoly::degree(), degree(), ::degree( v )

Definition at line 407 of file canonicalform.cc.

408 {
409  int what = is_imm( value );
410 #if 0
411  if ( what )
412  if ( what == FFMARK )
413  return imm_iszero_p( value ) ? -1 : 0;
414  else if ( what == INTMARK )
415  return imm_iszero( value ) ? -1 : 0;
416  else
417  return imm_iszero_gf( value ) ? -1 : 0;
418  else if ( value->inBaseDomain() )
419  return value->degree();
420 #else
421  switch(what)
422  {
423  case FFMARK: return imm_iszero_p( value ) ? -1 : 0;
424  case INTMARK: return imm_iszero( value ) ? -1 : 0;
425  case GFMARK: return imm_iszero_gf( value ) ? -1 : 0;
426  case 0: if ( value->inBaseDomain() )
427  return value->degree();
428  break;
429  }
430 #endif
431 
432  Variable x = value->variable();
433  if ( v == x )
434  return value->degree();
435  else if ( v > x )
436  // relatively to v, f is in a coefficient ring
437  return 0;
438  else {
439  int coeffdeg, result = 0;
440  // search for maximum of coefficient degree
441  for ( CFIterator i = *this; i.hasTerms(); i++ ) {
442  coeffdeg = i.coeff().degree( v );
443  if ( coeffdeg > result )
444  result = coeffdeg;
445  }
446  return result;
447  }
448 }

◆ degree() [5/6]

int CanonicalForm::degree ( const Variable v) const

◆ degree() [6/6]

int CanonicalForm::degree ( const Variable v) const

◆ den() [1/3]

CanonicalForm CanonicalForm::den ( ) const

den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!) otherwise.

See also
InternalCF::num(), InternalCF::den(), InternalRational::num(), InternalRational::den(), num(), den()

Definition at line 595 of file canonicalform.cc.

596 {
597  if ( is_imm( value ) )
598  return CanonicalForm( 1 );
599  else
600  return CanonicalForm( value->den() );
601 }

◆ den() [2/3]

CanonicalForm CanonicalForm::den ( ) const

◆ den() [3/3]

CanonicalForm CanonicalForm::den ( ) const

◆ deriv() [1/6]

CanonicalForm CanonicalForm::deriv ( ) const

deriv() - return the formal derivation of CO.

deriv() derives CO with respect to its main variable. Returns zero from the current domain if f is in a coefficient domain.

See also
CanonicalForm::deriv ( const Variable & x )

Definition at line 1235 of file canonicalform.cc.

1236 {
1237  if ( is_imm( value ) || value->inCoeffDomain() )
1238  return CanonicalForm( 0 );
1239  else {
1240  CanonicalForm result = 0;
1241  Variable x = value->variable();
1242  for ( CFIterator i = *this; i.hasTerms(); i++ )
1243  if ( i.exp() > 0 )
1244  result += power( x, i.exp()-1 ) * i.coeff() * i.exp();
1245  return result;
1246  }
1247 }

◆ deriv() [2/6]

CanonicalForm CanonicalForm::deriv ( ) const

◆ deriv() [3/6]

CanonicalForm CanonicalForm::deriv ( ) const

◆ deriv() [4/6]

CanonicalForm CanonicalForm::deriv ( const Variable x) const

deriv( x ) derives CO with respect to x.

x should be a polynomial variable. Returns zero from the current domain if f is in a coefficient domain.

Definition at line 1255 of file canonicalform.cc.

1256 {
1257  ASSERT( x.level() > 0, "cannot derive with respect to algebraic variables" );
1258  if ( is_imm( value ) || value->inCoeffDomain() )
1259  return CanonicalForm( 0 );
1260 
1261  Variable y = value->variable();
1262  if ( x > y )
1263  return CanonicalForm( 0 );
1264  else if ( x == y )
1265  return deriv();
1266  else {
1267  CanonicalForm result = 0;
1268  for ( CFIterator i = *this; i.hasTerms(); i++ )
1269  result += i.coeff().deriv( x ) * power( y, i.exp() );
1270  return result;
1271  }
1272 }

◆ deriv() [5/6]

CanonicalForm CanonicalForm::deriv ( const Variable x) const

◆ deriv() [6/6]

CanonicalForm CanonicalForm::deriv ( const Variable x) const

◆ div() [1/3]

CanonicalForm & CanonicalForm::div ( const CanonicalForm cf)

Definition at line 797 of file canonicalform.cc.

798 {
799  int what = is_imm( value );
800  if ( what ) {
801  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
802  if ( (what = is_imm( cf.value )) == FFMARK )
803  value = imm_div_p( value, cf.value );
804  else if ( what == GFMARK )
805  value = imm_div_gf( value, cf.value );
806  else if ( what )
807  value = imm_div( value, cf.value );
808  else {
809  InternalCF * dummy = cf.value->copyObject();
810  value = dummy->divcoeff( value, true );
811  }
812  }
813  else if ( is_imm( cf.value ) )
814  value = value->divcoeff( cf.value, false );
815  else if ( value->level() == cf.value->level() ) {
816  if ( value->levelcoeff() == cf.value->levelcoeff() )
817  value = value->divsame( cf.value );
818  else if ( value->levelcoeff() > cf.value->levelcoeff() )
819  value = value->divcoeff( cf.value, false );
820  else {
821  InternalCF * dummy = cf.value->copyObject();
822  dummy = dummy->divcoeff( value, true );
823  if ( value->deleteObject() ) delete value;
824  value = dummy;
825  }
826  }
827  else if ( level() > cf.level() )
828  value = value->divcoeff( cf.value, false );
829  else {
830  InternalCF * dummy = cf.value->copyObject();
831  dummy = dummy->divcoeff( value, true );
832  if ( value->deleteObject() ) delete value;
833  value = dummy;
834  }
835  return *this;
836 }

◆ div() [2/3]

CanonicalForm& CanonicalForm::div ( const CanonicalForm )

◆ div() [3/3]

CanonicalForm& CanonicalForm::div ( const CanonicalForm )

◆ genOne() [1/3]

CanonicalForm CanonicalForm::genOne ( ) const

Definition at line 1822 of file canonicalform.cc.

1823 {
1824  int what = is_imm( value );
1825  if ( what == FFMARK )
1827  else if ( what == GFMARK )
1829  else if ( what )
1830  return CanonicalForm( CFFactory::basic( IntegerDomain, 1L ) );
1831  else
1832  return CanonicalForm( value->genOne() );
1833 }

◆ genOne() [2/3]

CanonicalForm CanonicalForm::genOne ( ) const

◆ genOne() [3/3]

CanonicalForm CanonicalForm::genOne ( ) const

◆ genZero() [1/3]

CanonicalForm CanonicalForm::genZero ( ) const

genOne(), genZero()

Definition at line 1808 of file canonicalform.cc.

1809 {
1810  int what = is_imm( value );
1811  if ( what == FFMARK )
1813  else if ( what == GFMARK )
1815  else if ( what )
1816  return CanonicalForm( CFFactory::basic( IntegerDomain, 0L ) );
1817  else
1818  return CanonicalForm( value->genZero() );
1819 }

◆ genZero() [2/3]

CanonicalForm CanonicalForm::genZero ( ) const

◆ genZero() [3/3]

CanonicalForm CanonicalForm::genZero ( ) const

◆ getval() [1/3]

InternalCF * CanonicalForm::getval ( ) const

Definition at line 31 of file canonicalform.cc.

32 {
33  if ( is_imm( value ) )
34  return value;
35  else
36  return value->copyObject();
37 }

◆ getval() [2/3]

InternalCF* CanonicalForm::getval ( ) const

◆ getval() [3/3]

InternalCF* CanonicalForm::getval ( ) const

◆ ilog2() [1/3]

int CanonicalForm::ilog2 ( ) const

int CanonicalForm::ilog2 () const

ilog2() - integer logarithm to base 2.

Returns the largest integer less or equal logarithm of CO to base 2. CO should be a positive integer.

See also
InternalCF::ilog2(), InternalInteger::ilog2(), ilog2()

Definition at line 1352 of file canonicalform.cc.

1353 {
1354  if ( is_imm( value ) )
1355  {
1356  ASSERT( is_imm( value ) == INTMARK, "ilog2() not implemented" );
1357  long a = imm2int( value );
1358  ASSERT( a > 0, "arg to ilog2() less or equal zero" );
1359  int n = -1;
1360  while ( a > 0 )
1361  {
1362  n++;
1363  a /=2;
1364  }
1365  return n;
1366  }
1367  else
1368  return value->ilog2();
1369 }

◆ ilog2() [2/3]

int CanonicalForm::ilog2 ( ) const

◆ ilog2() [3/3]

int CanonicalForm::ilog2 ( ) const

◆ inBaseDomain() [1/3]

bool CanonicalForm::inBaseDomain ( ) const

Definition at line 101 of file canonicalform.cc.

102 {
103  if ( is_imm( value ) )
104  return true;
105  else
106  return value->inBaseDomain();
107 }

◆ inBaseDomain() [2/3]

bool CanonicalForm::inBaseDomain ( ) const

◆ inBaseDomain() [3/3]

bool CanonicalForm::inBaseDomain ( ) const

◆ inCoeffDomain() [1/3]

bool CanonicalForm::inCoeffDomain ( ) const

Definition at line 119 of file canonicalform.cc.

120 {
121  if ( is_imm( value ) )
122  return true;
123  else
124  return value->inCoeffDomain();
125 }

◆ inCoeffDomain() [2/3]

bool CanonicalForm::inCoeffDomain ( ) const

◆ inCoeffDomain() [3/3]

bool CanonicalForm::inCoeffDomain ( ) const

◆ inExtension() [1/3]

bool CanonicalForm::inExtension ( ) const

Definition at line 110 of file canonicalform.cc.

111 {
112  if ( is_imm( value ) )
113  return false;
114  else
115  return value->inExtension();
116 }

◆ inExtension() [2/3]

bool CanonicalForm::inExtension ( ) const

◆ inExtension() [3/3]

bool CanonicalForm::inExtension ( ) const

◆ inFF() [1/3]

bool CanonicalForm::inFF ( ) const

Definition at line 89 of file canonicalform.cc.

90 {
91  return is_imm( value ) == FFMARK;
92 }

◆ inFF() [2/3]

bool CanonicalForm::inFF ( ) const

◆ inFF() [3/3]

bool CanonicalForm::inFF ( ) const

◆ inGF() [1/3]

bool CanonicalForm::inGF ( ) const

Definition at line 95 of file canonicalform.cc.

96 {
97  return is_imm( value ) == GFMARK;
98 }

◆ inGF() [2/3]

bool CanonicalForm::inGF ( ) const

◆ inGF() [3/3]

bool CanonicalForm::inGF ( ) const

◆ inPolyDomain() [1/3]

bool CanonicalForm::inPolyDomain ( ) const

Definition at line 128 of file canonicalform.cc.

129 {
130  if ( is_imm( value ) )
131  return false;
132  else
133  return value->inPolyDomain();
134 }

◆ inPolyDomain() [2/3]

bool CanonicalForm::inPolyDomain ( ) const

◆ inPolyDomain() [3/3]

bool CanonicalForm::inPolyDomain ( ) const

◆ inQ() [1/3]

bool CanonicalForm::inQ ( ) const

Definition at line 77 of file canonicalform.cc.

78 {
79  if ( is_imm( value ) == INTMARK )
80  return true;
81  else if ( is_imm( value ) )
82  return false;
83  else
84  return value->levelcoeff() == IntegerDomain ||
86 }

◆ inQ() [2/3]

bool CanonicalForm::inQ ( ) const

◆ inQ() [3/3]

bool CanonicalForm::inQ ( ) const

◆ inQuotDomain() [1/3]

bool CanonicalForm::inQuotDomain ( ) const

Definition at line 137 of file canonicalform.cc.

138 {
139  if ( is_imm( value ) )
140  return false;
141  else
142  return value->inQuotDomain();
143 }

◆ inQuotDomain() [2/3]

bool CanonicalForm::inQuotDomain ( ) const

◆ inQuotDomain() [3/3]

bool CanonicalForm::inQuotDomain ( ) const

◆ intval() [1/3]

long CanonicalForm::intval ( ) const

conversion functions

Definition at line 197 of file canonicalform.cc.

198 {
199  if ( is_imm( value ) )
200  return imm_intval( value );
201  else
202  return value->intval();
203 }

◆ intval() [2/3]

long CanonicalForm::intval ( ) const

◆ intval() [3/3]

long CanonicalForm::intval ( ) const

◆ inZ() [1/3]

bool CanonicalForm::inZ ( ) const

predicates

Definition at line 66 of file canonicalform.cc.

67 {
68  if ( is_imm( value ) == INTMARK )
69  return true;
70  else if ( is_imm( value ) )
71  return false;
72  else
73  return value->levelcoeff() == IntegerDomain;
74 }

◆ inZ() [2/3]

bool CanonicalForm::inZ ( ) const

◆ inZ() [3/3]

bool CanonicalForm::inZ ( ) const

◆ isFFinGF() [1/3]

bool CanonicalForm::isFFinGF ( ) const

Definition at line 146 of file canonicalform.cc.

147 {
148  return is_imm( value ) == GFMARK && gf_isff( imm2int( value ) );
149 }

◆ isFFinGF() [2/3]

bool CanonicalForm::isFFinGF ( ) const

◆ isFFinGF() [3/3]

bool CanonicalForm::isFFinGF ( ) const

◆ isHomogeneous() [1/3]

bool CanonicalForm::isHomogeneous ( ) const

Definition at line 162 of file canonicalform.cc.

163 {
164  if (this->isZero()) return true;
165  else if (this->inCoeffDomain()) return true;
166  else
167  {
168 #if 0
169  CFIterator i;
170  int cdeg = -2, dummy;
171  for ( i = *this; i.hasTerms(); i++ )
172  {
173  if (!(i.coeff().isHomogeneous())) return false;
174  if ( (dummy = totaldegree( i.coeff() ) + i.exp()) != cdeg )
175  {
176  if (cdeg == -2) cdeg = dummy;
177  else return false;
178  }
179  }
180  return true;
181 #else
182  CFList termlist= get_Terms(*this);
184  int deg= totaldegree(termlist.getFirst());
185 
186  for ( i=termlist; i.hasItem(); i++ )
187  if ( totaldegree(i.getItem()) != deg ) return false;
188  return true;
189 #endif
190  }
191 }

◆ isHomogeneous() [2/3]

bool CanonicalForm::isHomogeneous ( ) const

◆ isHomogeneous() [3/3]

bool CanonicalForm::isHomogeneous ( ) const

◆ isImm() [1/3]

bool CanonicalForm::isImm ( ) const
inline

Definition at line 107 of file canonicalform.h.

107 { return is_imm( value ); };

◆ isImm() [2/3]

bool CanonicalForm::isImm ( ) const
inline

Definition at line 251 of file factory.h.

251 { return is_imm( value ); };

◆ isImm() [3/3]

bool CanonicalForm::isImm ( ) const
inline

Definition at line 251 of file factory.h.

251 { return is_imm( value ); };

◆ isOne() [1/3]

CF_INLINE bool CanonicalForm::isOne ( ) const

CF_INLINE bool CanonicalForm::isOne, isZero () const.

isOne(), isZero() - test whether a ‘CanonicalForm’ equals one or zero, resp.

The predicates ‘isOne()’ and ‘isZero()’ are much faster than the comparison operators. Furthermore, a test ‘f.isZero()’ is independent from the current domain, whereas an expression ‘f == 0’ is not.

Type info:

CO: Anything

Internal implementation:

Note that only immediate objects and objects of class ‘InternalPrimePower’ may equal one or zero, resp.

imm_isone(), imm_iszero() Trivial.

imm_isone_p(), imm_iszero_p() Trivial.

imm_isone_gf(), imm_iszero_gf() Use ‘gf_isone()’ and ‘gf_iszero()’, resp., to test whether CO equals zero or one, resp.

InternalCF::isOne(), isZero() Always return false.

InternalPrimePower::isOne(), isZero() Use ‘mpz_cpm_ui()’ resp. ‘mpz_sgn()’ to check the underlying mpi.

See also
CanonicalForm::isZero()

Definition at line 354 of file cf_inline.cc.

355 {
356  int what = is_imm( value );
357 
358  if ( ! what )
359  return value->isOne();
360  else if ( what == INTMARK )
361  return imm_isone( value );
362  else if ( what == FFMARK )
363  return imm_isone_p( value );
364  else
365  return imm_isone_gf( value );
366 }

◆ isOne() [2/3]

CF_NO_INLINE bool CanonicalForm::isOne ( ) const

◆ isOne() [3/3]

CF_NO_INLINE bool CanonicalForm::isOne ( ) const

◆ isUnivariate() [1/3]

bool CanonicalForm::isUnivariate ( ) const

Definition at line 152 of file canonicalform.cc.

153 {
154  if ( is_imm( value ) )
155  return false;
156  else
157  return value->isUnivariate();
158 }

◆ isUnivariate() [2/3]

bool CanonicalForm::isUnivariate ( ) const

◆ isUnivariate() [3/3]

bool CanonicalForm::isUnivariate ( ) const

◆ isZero() [1/3]

CF_INLINE bool CanonicalForm::isZero ( ) const
See also
CanonicalForm::isOne()

Definition at line 372 of file cf_inline.cc.

373 {
374  int what = is_imm( value );
375 
376  if ( what == 0 )
377  return value->isZero();
378  else if ( what == INTMARK )
379  return imm_iszero( value );
380  else if ( what == FFMARK )
381  return imm_iszero_p( value );
382  else
383  return imm_iszero_gf( value );
384 }

◆ isZero() [2/3]

CF_NO_INLINE bool CanonicalForm::isZero ( ) const

◆ isZero() [3/3]

CF_NO_INLINE bool CanonicalForm::isZero ( ) const

◆ lc() [1/3]

CanonicalForm CanonicalForm::lc ( ) const

CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const.

lc(), Lc(), LC() - leading coefficient functions.

All methods return CO if CO is in a base domain.

lc() returns the leading coefficient of CO with respect to lexicographic ordering. Elements in an algebraic extension are considered polynomials so lc() always returns a leading coefficient in a base domain. This method is useful to get the base domain over which CO is defined.

Lc() returns the leading coefficient of CO with respect to lexicographic ordering. In contrast to lc() elements in an algebraic extension are considered coefficients so Lc() always returns a leading coefficient in a coefficient domain.

LC() returns the leading coefficient of CO where CO is considered a univariate polynomial in its main variable. An element of an algebraic extension is considered an univariate polynomial, too.

LC( v ) returns the leading coefficient of CO where CO is considered an univariate polynomial in the polynomial variable v. Note: If v is less than the main variable of CO we have to swap variables which may be quite expensive.

Examples:

Let x < y be polynomial variables, a an algebraic variable.

(3*a*x*y^2+y+x).lc() = 3

(3*a*x*y^2+y+x).Lc() = 3*a

(3*a*x*y^2+y+x).LC() = 3*a*x

(3*a*x*y^2+y+x).LC( x ) = 3*a*y^2+1

(3*a^2+4*a).lc() = 3

(3*a^2+4*a).Lc() = 3*a^2+4*a

(3*a^2+4*a).LC() = 3

(3*a^2+4*a).LC( x ) = 3*a^2+4*a

See also
InternalCF::lc(), InternalCF::Lc(), InternalCF::LC(), InternalPoly::lc(), InternalPoly::Lc(), InternalPoly::LC(), lc(), Lc(), LC(), ::LC( v )

Definition at line 304 of file canonicalform.cc.

305 {
306  if ( is_imm( value ) )
307  return *this;
308  else
309  return value->lc();
310 }

◆ Lc() [1/3]

CanonicalForm CanonicalForm::Lc ( ) const
See also
CanonicalForm::lc(), CanonicalForm::LC(), InternalCF::lc(), InternalCF::Lc(), InternalCF::LC(), InternalPoly::lc(), InternalPoly::Lc(), InternalPoly::LC(), lc(), Lc(), LC(), ::LC( v )

Definition at line 319 of file canonicalform.cc.

320 {
321  if ( is_imm( value ) || value->inCoeffDomain() )
322  return *this;
323  else
324  return value->Lc();
325 }

◆ LC() [1/6]

CanonicalForm CanonicalForm::LC ( ) const
See also
CanonicalForm::lc(), CanonicalForm::Lc(), InternalCF::lc(), InternalCF::Lc(), InternalCF::LC(), InternalPoly::lc(), InternalPoly::Lc(), InternalPoly::LC(), lc(), Lc(), LC(), ::LC( v )

Definition at line 334 of file canonicalform.cc.

335 {
336  if ( is_imm( value ) )
337  return *this;
338  else
339  return value->LC();
340 }

◆ lc() [2/3]

CanonicalForm CanonicalForm::lc ( ) const

◆ Lc() [2/3]

CanonicalForm CanonicalForm::Lc ( ) const

◆ LC() [2/6]

CanonicalForm CanonicalForm::LC ( ) const

◆ lc() [3/3]

CanonicalForm CanonicalForm::lc ( ) const

◆ Lc() [3/3]

CanonicalForm CanonicalForm::Lc ( ) const

◆ LC() [3/6]

CanonicalForm CanonicalForm::LC ( ) const

◆ LC() [4/6]

CanonicalForm CanonicalForm::LC ( const Variable v) const
See also
CanonicalForm::lc(), CanonicalForm::Lc(), InternalCF::lc(), InternalCF::Lc(), InternalCF::LC(), InternalPoly::lc(), InternalPoly::Lc(), InternalPoly::LC(), lc(), Lc(), LC(), ::LC( v )

Definition at line 349 of file canonicalform.cc.

350 {
351  if ( is_imm( value ) || value->inCoeffDomain() )
352  return *this;
353 
354  Variable x = value->variable();
355  if ( v > x )
356  return *this;
357  else if ( v == x )
358  return value->LC();
359  else {
360  CanonicalForm f = swapvar( *this, v, x );
361  if ( f.mvar() == x )
362  return swapvar( f.value->LC(), v, x );
363  else
364  // v did not occur in f
365  return *this;
366  }
367 }

◆ LC() [5/6]

CanonicalForm CanonicalForm::LC ( const Variable v) const

◆ LC() [6/6]

CanonicalForm CanonicalForm::LC ( const Variable v) const

◆ level() [1/3]

int CanonicalForm::level ( ) const

level() returns the level of CO.

For a list of the levels and their meanings, see cf_defs.h.

See also
InternalCF::level(), InternalCF::variable(), InternalPoly::level(), InternalPoly::variable(), level(), mvar()

Definition at line 543 of file canonicalform.cc.

544 {
545  if ( is_imm( value ) )
546  return LEVELBASE;
547  else
548  return value->level();
549 }

◆ level() [2/3]

int CanonicalForm::level ( ) const

◆ level() [3/3]

int CanonicalForm::level ( ) const

◆ mapinto() [1/3]

CanonicalForm CanonicalForm::mapinto ( ) const

Definition at line 206 of file canonicalform.cc.

207 {
208  //ASSERT( is_imm( value ) || ! value->inExtension(), "cannot map into different Extension" );
209  if ( is_imm( value ) )
210  if ( getCharacteristic() == 0 )
211  if ( is_imm( value ) == FFMARK )
212  return CanonicalForm( int2imm( ff_symmetric( imm2int( value ) ) ) );
213  else if ( is_imm( value ) == GFMARK )
214  return CanonicalForm( int2imm( ff_symmetric( gf_gf2ff( imm2int( value ) ) ) ) );
215  else
216  return *this;
217  else if ( getGFDegree() == 1 )
218  return CanonicalForm( int2imm_p( ff_norm( imm2int( value ) ) ) );
219  else
220  return CanonicalForm( int2imm_gf( gf_int2gf( imm2int( value ) ) ) );
221  else if ( value->inBaseDomain() )
222  if ( getCharacteristic() == 0 )
223  return *this;
224  else
225  {
226  int val;
227  if ( value->levelcoeff() == IntegerDomain )
228  val = value->intmod( ff_prime );
229  else if ( value->levelcoeff() == RationalDomain )
230  return num().mapinto() / den().mapinto();
231  else {
232  ASSERT( 0, "illegal domain" );
233  return 0;
234  }
235  if ( getGFDegree() > 1 )
236  return CanonicalForm( int2imm_gf( gf_int2gf( val ) ) );
237  else
238  return CanonicalForm( int2imm_p( val ) );
239  }
240  else
241  {
242  Variable x = value->variable();
244  for ( CFIterator i = *this; i.hasTerms(); i++ )
245  result += (power( x, i.exp() ) * i.coeff().mapinto());
246  return result;
247  }
248 }

◆ mapinto() [2/3]

CanonicalForm CanonicalForm::mapinto ( ) const

◆ mapinto() [3/3]

CanonicalForm CanonicalForm::mapinto ( ) const

◆ mod() [1/3]

CanonicalForm & CanonicalForm::mod ( const CanonicalForm cf)

Definition at line 925 of file canonicalform.cc.

926 {
927  int what = is_imm( value );
928  if ( what ) {
929  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
930  if ( (what = is_imm( cf.value )) == FFMARK )
931  value = imm_mod_p( value, cf.value );
932  else if ( what == GFMARK )
933  value = imm_mod_gf( value, cf.value );
934  else if ( what )
935  value = imm_mod( value, cf.value );
936  else {
937  InternalCF * dummy = cf.value->copyObject();
938  value = dummy->modcoeff( value, true );
939  }
940  }
941  else if ( is_imm( cf.value ) )
942  value = value->modcoeff( cf.value, false );
943  else if ( value->level() == cf.value->level() ) {
944  if ( value->levelcoeff() == cf.value->levelcoeff() )
945  value = value->modsame( cf.value );
946  else if ( value->levelcoeff() > cf.value->levelcoeff() )
947  value = value->modcoeff( cf.value, false );
948  else {
949  InternalCF * dummy = cf.value->copyObject();
950  dummy = dummy->modcoeff( value, true );
951  if ( value->deleteObject() ) delete value;
952  value = dummy;
953  }
954  }
955  else if ( level() > cf.level() )
956  value = value->modcoeff( cf.value, false );
957  else {
958  InternalCF * dummy = cf.value->copyObject();
959  dummy = dummy->modcoeff( value, true );
960  if ( value->deleteObject() ) delete value;
961  value = dummy;
962  }
963  return *this;
964 }

◆ mod() [2/3]

CanonicalForm& CanonicalForm::mod ( const CanonicalForm )

◆ mod() [3/3]

CanonicalForm& CanonicalForm::mod ( const CanonicalForm )

◆ mpzval() [1/3]

void CanonicalForm::mpzval ( mpz_t  val) const

Definition at line 49 of file canonicalform.cc.

50 {
51  ASSERT (!is_imm (value) && value->levelcoeff() == IntegerDomain, "non-immediate integer expected");
52  getmpi (value, val);
53 }

◆ mpzval() [2/3]

void CanonicalForm::mpzval ( mpz_t  val) const

◆ mpzval() [3/3]

void CanonicalForm::mpzval ( mpz_t  val) const

◆ mvar() [1/3]

Variable CanonicalForm::mvar ( ) const

mvar() returns the main variable of CO or Variable() if CO is in a base domain.

See also
InternalCF::level(), InternalCF::variable(), InternalPoly::level(), InternalPoly::variable(), level(), mvar()

Definition at line 560 of file canonicalform.cc.

561 {
562  if ( is_imm( value ) )
563  return Variable();
564  else
565  return value->variable();
566 }

◆ mvar() [2/3]

Variable CanonicalForm::mvar ( ) const

◆ mvar() [3/3]

Variable CanonicalForm::mvar ( ) const

◆ num() [1/3]

CanonicalForm CanonicalForm::num ( ) const

num() returns the numerator of CO if CO is a rational number, CO itself otherwise.

See also
InternalCF::num(), InternalCF::den(), InternalRational::num(), InternalRational::den(), num(), den()

Definition at line 578 of file canonicalform.cc.

579 {
580  if ( is_imm( value ) )
581  return *this;
582  else
583  return CanonicalForm( value->num() );
584 }

◆ num() [2/3]

CanonicalForm CanonicalForm::num ( ) const

◆ num() [3/3]

CanonicalForm CanonicalForm::num ( ) const

◆ operator%=() [1/3]

CanonicalForm & CanonicalForm::operator%= ( const CanonicalForm cf)

Definition at line 883 of file canonicalform.cc.

884 {
885  int what = is_imm( value );
886  if ( what ) {
887  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
888  if ( (what = is_imm( cf.value )) == FFMARK )
889  value = imm_mod_p( value, cf.value );
890  else if ( what == GFMARK )
891  value = imm_mod_gf( value, cf.value );
892  else if ( what )
893  value = imm_mod( value, cf.value );
894  else {
895  InternalCF * dummy = cf.value->copyObject();
896  value = dummy->modulocoeff( value, true );
897  }
898  }
899  else if ( is_imm( cf.value ) )
900  value = value->modulocoeff( cf.value, false );
901  else if ( value->level() == cf.value->level() ) {
902  if ( value->levelcoeff() == cf.value->levelcoeff() )
903  value = value->modulosame( cf.value );
904  else if ( value->levelcoeff() > cf.value->levelcoeff() )
905  value = value->modulocoeff( cf.value, false );
906  else {
907  InternalCF * dummy = cf.value->copyObject();
908  dummy = dummy->modulocoeff( value, true );
909  if ( value->deleteObject() ) delete value;
910  value = dummy;
911  }
912  }
913  else if ( level() > cf.level() )
914  value = value->modulocoeff( cf.value, false );
915  else {
916  InternalCF * dummy = cf.value->copyObject();
917  dummy = dummy->modulocoeff( value, true );
918  if ( value->deleteObject() ) delete value;
919  value = dummy;
920  }
921  return *this;
922 }

◆ operator%=() [2/3]

CanonicalForm& CanonicalForm::operator%= ( const CanonicalForm )

◆ operator%=() [3/3]

CanonicalForm& CanonicalForm::operator%= ( const CanonicalForm )

◆ operator()() [1/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f) const

operator ()() - evaluation operator.

Returns CO if CO is in a base domain.

operator () ( f ) returns CO with f inserted for the main variable. Elements in an algebraic extension are considered polynomials.

Definition at line 1104 of file canonicalform.cc.

1105 {
1106  if ( is_imm( value ) || value->inBaseDomain() )
1107  return *this;
1108  else {
1109 #if 0
1110  CFIterator i = *this;
1111  int lastExp = i.exp();
1112  CanonicalForm result = i.coeff();
1113  i++;
1114  while ( i.hasTerms() ) {
1115  if ( (lastExp - i.exp()) == 1 )
1116  result *= f;
1117  else
1118  result *= power( f, lastExp - i.exp() );
1119  result += i.coeff();
1120  lastExp = i.exp();
1121  i++;
1122  }
1123  if ( lastExp != 0 )
1124  result *= power( f, lastExp );
1125 #else
1126  CFIterator i = *this;
1127  int lastExp = i.exp();
1128  CanonicalForm result = i.coeff();
1129  i++;
1130  while ( i.hasTerms() )
1131  {
1132  int i_exp=i.exp();
1133  if ( (lastExp - i_exp /* i.exp()*/) == 1 )
1134  result *= f;
1135  else
1136  result *= power( f, lastExp - i_exp /*i.exp()*/ );
1137  result += i.coeff();
1138  lastExp = i_exp /*i.exp()*/;
1139  i++;
1140  }
1141  if ( lastExp != 0 )
1142  result *= power( f, lastExp );
1143 #endif
1144  return result;
1145  }
1146 }

◆ operator()() [2/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f) const

◆ operator()() [3/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f) const

◆ operator()() [4/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f,
const Variable v 
) const

Returns CO if CO is in a base domain.

operator () ( f, v ) returns CO with f inserted for v. Elements in an algebraic extension are considered polynomials and v may be an algebraic variable.

Definition at line 1156 of file canonicalform.cc.

1157 {
1158  if ( is_imm( value ) || value->inBaseDomain() )
1159  return *this;
1160 
1161  Variable x = value->variable();
1162  if ( v > x )
1163  return *this;
1164  else if ( v == x )
1165  return (*this)( f );
1166  else {
1167  // v is less than main variable of f
1168  CanonicalForm result = 0;
1169  for ( CFIterator i = *this; i.hasTerms(); i++ )
1170  result += i.coeff()( f, v ) * power( x, i.exp() );
1171  return result;
1172  }
1173 }

◆ operator()() [5/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f,
const Variable v 
) const

◆ operator()() [6/6]

CanonicalForm CanonicalForm::operator() ( const CanonicalForm f,
const Variable v 
) const

◆ operator*=() [1/3]

CanonicalForm & CanonicalForm::operator*= ( const CanonicalForm cf)

Definition at line 689 of file canonicalform.cc.

690 {
691  int what = is_imm( value );
692  if ( what ) {
693  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
694  if ( (what = is_imm( cf.value )) == FFMARK )
695  value = imm_mul_p( value, cf.value );
696  else if ( what == GFMARK )
697  value = imm_mul_gf( value, cf.value );
698  else if ( what )
699  value = imm_mul( value, cf.value );
700  else {
701  InternalCF * dummy = cf.value->copyObject();
702  value = dummy->mulcoeff( value );
703  }
704  }
705  else if ( is_imm( cf.value ) )
706  value = value->mulcoeff( cf.value );
707  else if ( value->level() == cf.value->level() ) {
708 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
709  if (value->levelcoeff() == cf.value->levelcoeff() && cf.isUnivariate() && (*this).isUnivariate())
710  {
711  if (value->level() < 0 || CFFactory::gettype() == GaloisFieldDomain || (size (cf) <= 10 || size (*this) <= 10) )
712  value = value->mulsame( cf.value );
713  else
714  *this= mulNTL (*this, cf);
715  }
716  else if (value->levelcoeff() == cf.value->levelcoeff() && (!cf.isUnivariate() || !(*this).isUnivariate()))
717  value = value->mulsame( cf.value );
718 #else
719  if ( value->levelcoeff() == cf.value->levelcoeff() )
720  value = value->mulsame( cf.value );
721 #endif
722  else if ( value->levelcoeff() > cf.value->levelcoeff() )
723  value = value->mulcoeff( cf.value );
724  else {
725  InternalCF * dummy = cf.value->copyObject();
726  dummy = dummy->mulcoeff( value );
727  if ( value->deleteObject() ) delete value;
728  value = dummy;
729  }
730  }
731  else if ( level() > cf.level() )
732  value = value->mulcoeff( cf.value );
733  else {
734  InternalCF * dummy = cf.value->copyObject();
735  dummy = dummy->mulcoeff( value );
736  if ( value->deleteObject() ) delete value;
737  value = dummy;
738  }
739  return *this;
740 }

◆ operator*=() [2/3]

CanonicalForm& CanonicalForm::operator*= ( const CanonicalForm )

◆ operator*=() [3/3]

CanonicalForm& CanonicalForm::operator*= ( const CanonicalForm )

◆ operator+=() [1/3]

CanonicalForm & CanonicalForm::operator+= ( const CanonicalForm cf)

assignment operators

Definition at line 605 of file canonicalform.cc.

606 {
607  int what = is_imm( value );
608  if ( what ) {
609  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
610  if ( (what = is_imm( cf.value )) == FFMARK )
611  value = imm_add_p( value, cf.value );
612  else if ( what == GFMARK )
613  value = imm_add_gf( value, cf.value );
614  else if ( what )
615  value = imm_add( value, cf.value );
616  else {
617  InternalCF * dummy = cf.value->copyObject();
618  value = dummy->addcoeff( value );
619  }
620  }
621  else if ( is_imm( cf.value ) )
622  value = value->addcoeff( cf.value );
623  else if ( value->level() == cf.value->level() ) {
624  if ( value->levelcoeff() == cf.value->levelcoeff() )
625  value = value->addsame( cf.value );
626  else if ( value->levelcoeff() > cf.value->levelcoeff() )
627  value = value->addcoeff( cf.value );
628  else {
629  InternalCF * dummy = cf.value->copyObject();
630  dummy = dummy->addcoeff( value );
631  if ( value->deleteObject() ) delete value;
632  value = dummy;
633  }
634  }
635  else if ( level() > cf.level() )
636  value = value->addcoeff( cf.value );
637  else {
638  InternalCF * dummy = cf.value->copyObject();
639  dummy = dummy->addcoeff( value );
640  if ( value->deleteObject() ) delete value;
641  value = dummy;
642  }
643  return *this;
644 }

◆ operator+=() [2/3]

CanonicalForm& CanonicalForm::operator+= ( const CanonicalForm )

◆ operator+=() [3/3]

CanonicalForm& CanonicalForm::operator+= ( const CanonicalForm )

◆ operator-=() [1/3]

CanonicalForm & CanonicalForm::operator-= ( const CanonicalForm cf)

Definition at line 647 of file canonicalform.cc.

648 {
649  int what = is_imm( value );
650  if ( what ) {
651  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
652  if ( (what = is_imm( cf.value )) == FFMARK )
653  value = imm_sub_p( value, cf.value );
654  else if ( what == GFMARK )
655  value = imm_sub_gf( value, cf.value );
656  else if ( what )
657  value = imm_sub( value, cf.value );
658  else {
659  InternalCF * dummy = cf.value->copyObject();
660  value = dummy->subcoeff( value, true );
661  }
662  }
663  else if ( is_imm( cf.value ) )
664  value = value->subcoeff( cf.value, false );
665  else if ( value->level() == cf.value->level() ) {
666  if ( value->levelcoeff() == cf.value->levelcoeff() )
667  value = value->subsame( cf.value );
668  else if ( value->levelcoeff() > cf.value->levelcoeff() )
669  value = value->subcoeff( cf.value, false );
670  else {
671  InternalCF * dummy = cf.value->copyObject();
672  dummy = dummy->subcoeff( value, true );
673  if ( value->deleteObject() ) delete value;
674  value = dummy;
675  }
676  }
677  else if ( level() > cf.level() )
678  value = value->subcoeff( cf.value, false );
679  else {
680  InternalCF * dummy = cf.value->copyObject();
681  dummy = dummy->subcoeff( value, true );
682  if ( value->deleteObject() ) delete value;
683  value = dummy;
684  }
685  return *this;
686 }

◆ operator-=() [2/3]

CanonicalForm& CanonicalForm::operator-= ( const CanonicalForm )

◆ operator-=() [3/3]

CanonicalForm& CanonicalForm::operator-= ( const CanonicalForm )

◆ operator/=() [1/3]

CanonicalForm & CanonicalForm::operator/= ( const CanonicalForm cf)

Definition at line 743 of file canonicalform.cc.

744 {
745  int what = is_imm( value );
746  if ( what ) {
747  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
748  if ( (what = is_imm( cf.value )) == FFMARK )
749  value = imm_div_p( value, cf.value );
750  else if ( what == GFMARK )
751  value = imm_div_gf( value, cf.value );
752  else if ( what )
753  value = imm_divrat( value, cf.value );
754  else {
755  InternalCF * dummy = cf.value->copyObject();
756  value = dummy->dividecoeff( value, true );
757  }
758  }
759  else if ( is_imm( cf.value ) )
760  value = value->dividecoeff( cf.value, false );
761  else if ( value->level() == cf.value->level() ) {
762 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
763  if ( value->levelcoeff() == cf.value->levelcoeff() && (*this).isUnivariate() && cf.isUnivariate())
764  {
765  if (value->level() < 0 || CFFactory::gettype() == GaloisFieldDomain)
766  value = value->dividesame( cf.value );
767  else
768  *this= divNTL (*this, cf);
769  }
770  else if (value->levelcoeff() == cf.value->levelcoeff() && (!cf.isUnivariate() || !(*this).isUnivariate()))
771  value = value->dividesame( cf.value );
772 #else
773  if (value->levelcoeff() == cf.value->levelcoeff() )
774  value = value->dividesame( cf.value );
775 #endif
776  else if ( value->levelcoeff() > cf.value->levelcoeff() )
777  value = value->dividecoeff( cf.value, false );
778  else {
779  InternalCF * dummy = cf.value->copyObject();
780  dummy = dummy->dividecoeff( value, true );
781  if ( value->deleteObject() ) delete value;
782  value = dummy;
783  }
784  }
785  else if ( level() > cf.level() )
786  value = value->dividecoeff( cf.value, false );
787  else {
788  InternalCF * dummy = cf.value->copyObject();
789  dummy = dummy->dividecoeff( value, true );
790  if ( value->deleteObject() ) delete value;
791  value = dummy;
792  }
793  return *this;
794 }

◆ operator/=() [2/3]

CanonicalForm& CanonicalForm::operator/= ( const CanonicalForm )

◆ operator/=() [3/3]

CanonicalForm& CanonicalForm::operator/= ( const CanonicalForm )

◆ operator=() [1/6]

CF_INLINE CanonicalForm & CanonicalForm::operator= ( const CanonicalForm cf)

CF_INLINE CanonicalForm & CanonicalForm::operator = ( const CanonicalForm & cf )

operator =() - assign ‘cf’ to CO.

Type info:

CO, cf: Anything

Definition at line 272 of file cf_inline.cc.

273 {
274  if ( this != &cf ) {
275  if ( (! is_imm( value )) && value->deleteObject() )
276  delete value;
277  value = (is_imm( cf.value )) ? cf.value : cf.value->copyObject();
278  }
279  return *this;
280 }

◆ operator=() [2/6]

CF_NO_INLINE CanonicalForm& CanonicalForm::operator= ( const CanonicalForm )

◆ operator=() [3/6]

CF_NO_INLINE CanonicalForm& CanonicalForm::operator= ( const CanonicalForm )

◆ operator=() [4/6]

CF_INLINE CanonicalForm & CanonicalForm::operator= ( const long  cf)

operator =() - assign long ‘cf’ to CO.

‘cf’ converted to a canonical form as described in the canonical form constructor which creates a canonical form from an integer.

Type info:

CO: Anything

Developers note:

Strictly speaking, this operator is superfluous. The ordinary assignment operator together with automatic conversion from ‘int’ to ‘CanonicalForm’ would do the job, too. But this way the common operation of assigning an integer is faster.

Definition at line 303 of file cf_inline.cc.

304 {
305  if ( (! is_imm( value )) && value->deleteObject() )
306  delete value;
308  return *this;
309 }

◆ operator=() [5/6]

CF_NO_INLINE CanonicalForm& CanonicalForm::operator= ( const long  )

◆ operator=() [6/6]

CF_NO_INLINE CanonicalForm& CanonicalForm::operator= ( const long  )

◆ operator[]() [1/3]

CanonicalForm CanonicalForm::operator[] ( int  i) const

operator []() - return i'th coefficient from CO.

Returns CO if CO is in a base domain and i equals zero. Returns zero (from the current domain) if CO is in a base domain and i is larger than zero. Otherwise, returns the coefficient to x^i in CO (if x denotes the main variable of CO) or zero if CO does not contain x^i. Elements in an algebraic extension are considered polynomials. i should be larger or equal zero.

Note: Never use a loop like

for ( int i = degree( f ); i >= 0; i-- )
foo( i, f[ i ] );

which is much slower than

for ( int i = degree( f ), CFIterator I = f; I.hasTerms(); I++ ) {
// fill gap with zeroes
for ( ; i > I.exp(); i-- )
foo( i, 0 );
// at this point, i == I.exp()
foo( i, i.coeff() );
i--;
}
// work through trailing zeroes
for ( ; i >= 0; i-- )
foo( i, 0 );

Definition at line 1212 of file canonicalform.cc.

1213 {
1214  ASSERT( i >= 0, "index to operator [] less than zero" );
1215  if ( is_imm( value ) )
1216  if ( i == 0 )
1217  return *this;
1218  else
1219  return CanonicalForm( 0 );
1220  else
1221  return value->coeff( i );
1222 }

◆ operator[]() [2/3]

CanonicalForm CanonicalForm::operator[] ( int  i) const

◆ operator[]() [3/3]

CanonicalForm CanonicalForm::operator[] ( int  i) const

◆ print() [1/6]

void CanonicalForm::print ( OSTREAM os) const

Definition at line 1783 of file canonicalform.cc.

1784 {
1785  if ( is_imm( value ) )
1786  imm_print( os, value, "" );
1787  else
1788  value->print( os, "" );
1789 }

◆ print() [2/6]

void CanonicalForm::print ( OSTREAM ) const

◆ print() [3/6]

void CanonicalForm::print ( OSTREAM ) const

◆ print() [4/6]

void CanonicalForm::print ( OSTREAM os,
char *  str 
) const

input/output

Definition at line 1774 of file canonicalform.cc.

1775 {
1776  if ( is_imm( value ) )
1777  imm_print( os, value, str );
1778  else
1779  value->print( os, str );
1780 }

◆ print() [5/6]

void CanonicalForm::print ( OSTREAM ,
char *   
) const

◆ print() [6/6]

void CanonicalForm::print ( OSTREAM ,
char *   
) const

◆ sign() [1/3]

int CanonicalForm::sign ( ) const

int CanonicalForm::sign () const

sign() - return sign of CO.

If CO is an integer or a rational number, the sign is defined as usual. If CO is an element of a prime power domain or of FF(p) and SW_SYMMETRIC_FF is on, the sign of CO is the sign of the symmetric representation of CO. If CO is in GF(q) or in FF(p) and SW_SYMMETRIC_FF is off, the sign of CO is zero iff CO is zero, otherwise the sign is one.

If CO is a polynomial or in an extension of one of the base domains, the sign of CO is the sign of its leading coefficient.

See also
InternalCF::sign(), InternalInteger::sign(), InternalRational::sign(), InternalPoly::sign(), imm_sign(), gf_sign()

Definition at line 1295 of file canonicalform.cc.

1296 {
1297  if ( is_imm( value ) )
1298  return imm_sign( value );
1299  else
1300  return value->sign();
1301 }

◆ sign() [2/3]

int CanonicalForm::sign ( ) const

◆ sign() [3/3]

int CanonicalForm::sign ( ) const

◆ sqrt() [1/3]

CanonicalForm CanonicalForm::sqrt ( ) const

CanonicalForm CanonicalForm::sqrt () const.

sqrt() - calculate integer square root.

CO has to be an integer greater or equal zero. Returns the largest integer less or equal sqrt(CO).

In the immediate case, we use the newton method to find the root. The algorithm is from H. Cohen - 'A Course in Computational Algebraic Number Theory', ch. 1.7.1.

See also
InternalCF::sqrt(), InternalInteger::sqrt(), sqrt()

Definition at line 1318 of file canonicalform.cc.

1319 {
1320  if ( is_imm( value ) ) {
1321  ASSERT( is_imm( value ) == INTMARK, "sqrt() not implemented" );
1322  long n = imm2int( value );
1323  ASSERT( n >= 0, "arg to sqrt() less than zero" );
1324  if ( n == 0 || n == 1 )
1325  return CanonicalForm( n );
1326  else {
1327  long x, y = n;
1328  do {
1329  x = y;
1330  // the intermediate result may not fit into an
1331  // integer, but the result does
1332  y = (unsigned long)(x + n/x)/2;
1333  } while ( y < x );
1334  return CanonicalForm( x );
1335  }
1336  }
1337  else
1338  return CanonicalForm( value->sqrt() );
1339 }

◆ sqrt() [2/3]

CanonicalForm CanonicalForm::sqrt ( ) const

◆ sqrt() [3/3]

CanonicalForm CanonicalForm::sqrt ( ) const

◆ tailcoeff() [1/6]

CanonicalForm CanonicalForm::tailcoeff ( ) const

tailcoeff() - return least coefficient

tailcoeff() returns the coefficient of the term with the least degree in CO where CO is considered an univariate polynomial in its main variable. Elements in an algebraic extension are considered coefficients.

See also
CanonicalForm::taildegree(), InternalCF::tailcoeff(), InternalCF::tailcoeff(), InternalPoly::tailcoeff(), InternalPoly::taildegree, tailcoeff(), taildegree()

Definition at line 465 of file canonicalform.cc.

466 {
467  if ( is_imm( value ) || value->inCoeffDomain() )
468  return *this;
469  else
470  return value->tailcoeff();
471 }

◆ tailcoeff() [2/6]

CanonicalForm CanonicalForm::tailcoeff ( ) const

◆ tailcoeff() [3/6]

CanonicalForm CanonicalForm::tailcoeff ( ) const

◆ tailcoeff() [4/6]

CanonicalForm CanonicalForm::tailcoeff ( const Variable v) const

tailcoeff( v ) returns the tail coefficient of CO where CO is considered an univariate polynomial in the polynomial variable v.

Note: If v is less than the main variable of CO we have to swap variables which may be quite expensive.

See also
CanonicalForm::taildegree(), InternalCF::tailcoeff(), InternalCF::tailcoeff(), InternalPoly::tailcoeff(), InternalPoly::taildegree, tailcoeff(), taildegree()

Definition at line 485 of file canonicalform.cc.

486 {
487  if ( is_imm( value ) || value->inCoeffDomain() )
488  return *this;
489 
490  Variable x = value->variable();
491  if ( v > x )
492  return *this;
493  else if ( v == x )
494  return value->tailcoeff();
495  else {
496  CanonicalForm f = swapvar( *this, v, x );
497  if ( f.mvar() == x )
498  return swapvar( f.value->tailcoeff(), v, x );
499  else
500  // v did not occur in f
501  return *this;
502  }
503 }

◆ tailcoeff() [5/6]

CanonicalForm CanonicalForm::tailcoeff ( const Variable v) const

◆ tailcoeff() [6/6]

CanonicalForm CanonicalForm::tailcoeff ( const Variable v) const

◆ taildegree() [1/3]

int CanonicalForm::taildegree ( ) const

taildegree() returns -1 for the zero polynomial, 0 if CO is in a base domain, otherwise the least degree of CO where CO is considered a univariate polynomial in its main variable.

In contrast to tailcoeff(), elements in an algebraic extension are considered polynomials, not coefficients, and such may have a taildegree larger than zero.

See also
CanonicalForm::tailcoeff(), InternalCF::tailcoeff(), InternalCF::tailcoeff(), InternalPoly::tailcoeff(), InternalPoly::taildegree, tailcoeff(), taildegree()

Definition at line 519 of file canonicalform.cc.

520 {
521  int what = is_imm( value );
522  if ( what )
523  if ( what == FFMARK )
524  return imm_iszero_p( value ) ? -1 : 0;
525  else if ( what == INTMARK )
526  return imm_iszero( value ) ? -1 : 0;
527  else
528  return imm_iszero_gf( value ) ? -1 : 0;
529  else
530  return value->taildegree();
531 }

◆ taildegree() [2/3]

int CanonicalForm::taildegree ( ) const

◆ taildegree() [3/3]

int CanonicalForm::taildegree ( ) const

◆ tryDiv() [1/3]

CanonicalForm & CanonicalForm::tryDiv ( const CanonicalForm cf,
const CanonicalForm M,
bool &  fail 
)

same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible

Definition at line 840 of file canonicalform.cc.

841 {
842  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
843  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
844  fail= false;
845  int what = is_imm( value );
846  if ( what ) {
847  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
848  if ( (what = is_imm( cf.value )) == FFMARK )
849  value = imm_div_p( value, cf.value );
850  else if ( what == GFMARK )
851  value = imm_div_gf( value, cf.value );
852  else {
853  InternalCF * dummy = cf.value->copyObject();
854  value = dummy->divcoeff( value, true );
855  }
856  }
857  else if ( is_imm( cf.value ) )
858  value = value->tryDivcoeff (cf.value, false, M, fail);
859  else if ( value->level() == cf.value->level() ) {
860  if ( value->levelcoeff() == cf.value->levelcoeff() )
861  value = value->tryDivsame( cf.value, M, fail );
862  else if ( value->levelcoeff() > cf.value->levelcoeff() )
863  value = value->tryDivcoeff( cf.value, false, M, fail );
864  else {
865  InternalCF * dummy = cf.value->copyObject();
866  dummy = dummy->tryDivcoeff( value, true, M, fail );
867  if ( value->deleteObject() ) delete value;
868  value = dummy;
869  }
870  }
871  else if ( level() > cf.level() )
872  value = value->tryDivcoeff( cf.value, false, M, fail );
873  else {
874  InternalCF * dummy = cf.value->copyObject();
875  dummy = dummy->tryDivcoeff( value, true, M, fail );
876  if ( value->deleteObject() ) delete value;
877  value = dummy;
878  }
879  return *this;
880 }

◆ tryDiv() [2/3]

CanonicalForm& CanonicalForm::tryDiv ( const CanonicalForm ,
const CanonicalForm ,
bool &   
)

◆ tryDiv() [3/3]

CanonicalForm& CanonicalForm::tryDiv ( const CanonicalForm ,
const CanonicalForm ,
bool &   
)

Friends And Related Function Documentation

◆ bextgcd [1/3]

CanonicalForm bextgcd ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm a,
CanonicalForm b 
)
friend

CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )

bextgcd() - return base coefficient extended gcd.

Definition at line 1663 of file canonicalform.cc.

1664 {
1665  // check immediate cases
1666  int what = is_imm( g.value );
1667  if ( is_imm( f.value ) ) {
1668  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1669  if ( what == 0 )
1670  return g.value->bextgcdcoeff( f.value, b, a );
1671  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1672  // calculate extended gcd using standard integer
1673  // arithmetic
1674  long fInt = imm2int( f.value );
1675  long gInt = imm2int( g.value );
1676 
1677  // to avoid any system dpendencies with `%', we work
1678  // with positive numbers only. To a pity, we have to
1679  // redo all the checks when assigning to a and b.
1680  if ( fInt < 0 ) fInt = -fInt;
1681  if ( gInt < 0 ) gInt = -gInt;
1682  // swap fInt and gInt
1683  if ( gInt > fInt ) {
1684  long swap = gInt;
1685  gInt = fInt;
1686  fInt = swap;
1687  }
1688 
1689  long u = 1; long v = 0;
1690  long uNext = 0; long vNext = 1;
1691 
1692  // at any step, we have:
1693  // fInt_0 * u + gInt_0 * v = fInt
1694  // fInt_0 * uNext + gInt_0 * vNext = gInt
1695  // where fInt_0 and gInt_0 denote the values of fint
1696  // and gInt, resp., at the beginning
1697  while ( gInt ) {
1698  long r = fInt % gInt;
1699  long q = fInt / gInt;
1700  long uSwap = u - q * uNext;
1701  long vSwap = v - q * vNext;
1702 
1703  // update variables
1704  fInt = gInt;
1705  gInt = r;
1706  u = uNext; v = vNext;
1707  uNext = uSwap; vNext = vSwap;
1708  }
1709 
1710  // now, assign to a and b
1711  long fTest = imm2int( f.value );
1712  long gTest = imm2int( g.value );
1713  if ( gTest > fTest ) {
1714  a = v; b = u;
1715  } else {
1716  a = u; b = v;
1717  }
1718  if ( fTest < 0 ) a = -a;
1719  if ( gTest < 0 ) b = -b;
1720  return CanonicalForm( fInt );
1721  } else
1722  // stupid special cases
1723  if ( ! f.isZero() ) {
1724  a = 1/f; b = 0; return CanonicalForm( 1L );
1725  } else if ( ! g.isZero() ) {
1726  a = 0; b = 1/g; return CanonicalForm( 1L );
1727  } else {
1728  a = 0; b = 0; return CanonicalForm( 0L );
1729  }
1730  }
1731  else if ( what )
1732  return f.value->bextgcdcoeff( g.value, a, b );
1733 
1734  int fLevel = f.value->level();
1735  int gLevel = g.value->level();
1736 
1737  // check levels
1738  if ( fLevel == gLevel ) {
1739  fLevel = f.value->levelcoeff();
1740  gLevel = g.value->levelcoeff();
1741 
1742  // check levelcoeffs
1743  if ( fLevel == gLevel )
1744  return f.value->bextgcdsame( g.value, a, b );
1745  else if ( fLevel < gLevel )
1746  return g.value->bextgcdcoeff( f.value, b, a );
1747  else
1748  return f.value->bextgcdcoeff( g.value, a, b );
1749  }
1750  else if ( fLevel < gLevel )
1751  return g.value->bextgcdcoeff( f.value, b, a );
1752  else
1753  return f.value->bextgcdcoeff( g.value, a, b );
1754 }

◆ bextgcd [2/3]

CanonicalForm bextgcd ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm a,
CanonicalForm b 
)
friend

CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )

bextgcd() - return base coefficient extended gcd.

Definition at line 1663 of file canonicalform.cc.

1664 {
1665  // check immediate cases
1666  int what = is_imm( g.value );
1667  if ( is_imm( f.value ) ) {
1668  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1669  if ( what == 0 )
1670  return g.value->bextgcdcoeff( f.value, b, a );
1671  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1672  // calculate extended gcd using standard integer
1673  // arithmetic
1674  long fInt = imm2int( f.value );
1675  long gInt = imm2int( g.value );
1676 
1677  // to avoid any system dpendencies with `%', we work
1678  // with positive numbers only. To a pity, we have to
1679  // redo all the checks when assigning to a and b.
1680  if ( fInt < 0 ) fInt = -fInt;
1681  if ( gInt < 0 ) gInt = -gInt;
1682  // swap fInt and gInt
1683  if ( gInt > fInt ) {
1684  long swap = gInt;
1685  gInt = fInt;
1686  fInt = swap;
1687  }
1688 
1689  long u = 1; long v = 0;
1690  long uNext = 0; long vNext = 1;
1691 
1692  // at any step, we have:
1693  // fInt_0 * u + gInt_0 * v = fInt
1694  // fInt_0 * uNext + gInt_0 * vNext = gInt
1695  // where fInt_0 and gInt_0 denote the values of fint
1696  // and gInt, resp., at the beginning
1697  while ( gInt ) {
1698  long r = fInt % gInt;
1699  long q = fInt / gInt;
1700  long uSwap = u - q * uNext;
1701  long vSwap = v - q * vNext;
1702 
1703  // update variables
1704  fInt = gInt;
1705  gInt = r;
1706  u = uNext; v = vNext;
1707  uNext = uSwap; vNext = vSwap;
1708  }
1709 
1710  // now, assign to a and b
1711  long fTest = imm2int( f.value );
1712  long gTest = imm2int( g.value );
1713  if ( gTest > fTest ) {
1714  a = v; b = u;
1715  } else {
1716  a = u; b = v;
1717  }
1718  if ( fTest < 0 ) a = -a;
1719  if ( gTest < 0 ) b = -b;
1720  return CanonicalForm( fInt );
1721  } else
1722  // stupid special cases
1723  if ( ! f.isZero() ) {
1724  a = 1/f; b = 0; return CanonicalForm( 1L );
1725  } else if ( ! g.isZero() ) {
1726  a = 0; b = 1/g; return CanonicalForm( 1L );
1727  } else {
1728  a = 0; b = 0; return CanonicalForm( 0L );
1729  }
1730  }
1731  else if ( what )
1732  return f.value->bextgcdcoeff( g.value, a, b );
1733 
1734  int fLevel = f.value->level();
1735  int gLevel = g.value->level();
1736 
1737  // check levels
1738  if ( fLevel == gLevel ) {
1739  fLevel = f.value->levelcoeff();
1740  gLevel = g.value->levelcoeff();
1741 
1742  // check levelcoeffs
1743  if ( fLevel == gLevel )
1744  return f.value->bextgcdsame( g.value, a, b );
1745  else if ( fLevel < gLevel )
1746  return g.value->bextgcdcoeff( f.value, b, a );
1747  else
1748  return f.value->bextgcdcoeff( g.value, a, b );
1749  }
1750  else if ( fLevel < gLevel )
1751  return g.value->bextgcdcoeff( f.value, b, a );
1752  else
1753  return f.value->bextgcdcoeff( g.value, a, b );
1754 }

◆ bextgcd [3/3]

CanonicalForm bextgcd ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm a,
CanonicalForm b 
)
friend

CanonicalForm bextgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a, CanonicalForm & b )

bextgcd() - return base coefficient extended gcd.

Definition at line 1663 of file canonicalform.cc.

1664 {
1665  // check immediate cases
1666  int what = is_imm( g.value );
1667  if ( is_imm( f.value ) ) {
1668  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1669  if ( what == 0 )
1670  return g.value->bextgcdcoeff( f.value, b, a );
1671  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1672  // calculate extended gcd using standard integer
1673  // arithmetic
1674  long fInt = imm2int( f.value );
1675  long gInt = imm2int( g.value );
1676 
1677  // to avoid any system dpendencies with `%', we work
1678  // with positive numbers only. To a pity, we have to
1679  // redo all the checks when assigning to a and b.
1680  if ( fInt < 0 ) fInt = -fInt;
1681  if ( gInt < 0 ) gInt = -gInt;
1682  // swap fInt and gInt
1683  if ( gInt > fInt ) {
1684  long swap = gInt;
1685  gInt = fInt;
1686  fInt = swap;
1687  }
1688 
1689  long u = 1; long v = 0;
1690  long uNext = 0; long vNext = 1;
1691 
1692  // at any step, we have:
1693  // fInt_0 * u + gInt_0 * v = fInt
1694  // fInt_0 * uNext + gInt_0 * vNext = gInt
1695  // where fInt_0 and gInt_0 denote the values of fint
1696  // and gInt, resp., at the beginning
1697  while ( gInt ) {
1698  long r = fInt % gInt;
1699  long q = fInt / gInt;
1700  long uSwap = u - q * uNext;
1701  long vSwap = v - q * vNext;
1702 
1703  // update variables
1704  fInt = gInt;
1705  gInt = r;
1706  u = uNext; v = vNext;
1707  uNext = uSwap; vNext = vSwap;
1708  }
1709 
1710  // now, assign to a and b
1711  long fTest = imm2int( f.value );
1712  long gTest = imm2int( g.value );
1713  if ( gTest > fTest ) {
1714  a = v; b = u;
1715  } else {
1716  a = u; b = v;
1717  }
1718  if ( fTest < 0 ) a = -a;
1719  if ( gTest < 0 ) b = -b;
1720  return CanonicalForm( fInt );
1721  } else
1722  // stupid special cases
1723  if ( ! f.isZero() ) {
1724  a = 1/f; b = 0; return CanonicalForm( 1L );
1725  } else if ( ! g.isZero() ) {
1726  a = 0; b = 1/g; return CanonicalForm( 1L );
1727  } else {
1728  a = 0; b = 0; return CanonicalForm( 0L );
1729  }
1730  }
1731  else if ( what )
1732  return f.value->bextgcdcoeff( g.value, a, b );
1733 
1734  int fLevel = f.value->level();
1735  int gLevel = g.value->level();
1736 
1737  // check levels
1738  if ( fLevel == gLevel ) {
1739  fLevel = f.value->levelcoeff();
1740  gLevel = g.value->levelcoeff();
1741 
1742  // check levelcoeffs
1743  if ( fLevel == gLevel )
1744  return f.value->bextgcdsame( g.value, a, b );
1745  else if ( fLevel < gLevel )
1746  return g.value->bextgcdcoeff( f.value, b, a );
1747  else
1748  return f.value->bextgcdcoeff( g.value, a, b );
1749  }
1750  else if ( fLevel < gLevel )
1751  return g.value->bextgcdcoeff( f.value, b, a );
1752  else
1753  return f.value->bextgcdcoeff( g.value, a, b );
1754 }

◆ bgcd [1/3]

CanonicalForm bgcd ( const CanonicalForm f,
const CanonicalForm g 
)
friend

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

bgcd() - return base coefficient gcd.

If both f and g are integers and ‘SW_RATIONAL’ is off the positive greatest common divisor of f and g is returned. Otherwise, if ‘SW_RATIONAL’ is on or one of f and g is not an integer, the greatest common divisor is trivial: either zero if f and g equal zero or one (both from the current domain).

f and g should come from one base domain which should be not the prime power domain.

Implementation:

CanonicalForm::bgcd() handles the immediate case with a standard euclidean algorithm. For the non-immediate cases ‘InternalCF::bgcdsame()’ or ‘InternalCF::bgcdcoeff()’, resp. are called following the usual level/levelcoeff approach.

InternalCF::bgcdsame() and InternalCF::bgcdcoeff() throw an assertion ("not implemented")

InternalInteger::bgcdsame() is a wrapper around ‘mpz_gcd()’ which takes some care about immediate results and the sign of the result InternalInteger::bgcdcoeff() is a wrapper around ‘mpz_gcd_ui()’ which takes some care about the sign of the result

InternalRational::bgcdsame() and InternalRational::bgcdcoeff() always return one

Definition at line 1589 of file canonicalform.cc.

1590 {
1591  // check immediate cases
1592  int what = is_imm( g.value );
1593  if ( is_imm( f.value ) )
1594  {
1595  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1596  if ( what == 0 )
1597  return g.value->bgcdcoeff( f.value );
1598  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1599  {
1600  // calculate gcd using standard integer
1601  // arithmetic
1602  long fInt = imm2int( f.value );
1603  long gInt = imm2int( g.value );
1604 
1605  if ( fInt < 0 ) fInt = -fInt;
1606  if ( gInt < 0 ) gInt = -gInt;
1607  // swap fInt and gInt
1608  if ( gInt > fInt )
1609  {
1610  long swap = gInt;
1611  gInt = fInt;
1612  fInt = swap;
1613  }
1614 
1615  // now, 0 <= gInt <= fInt. Start the loop.
1616  while ( gInt )
1617  {
1618  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1619  long r = fInt % gInt;
1620  fInt = gInt;
1621  gInt = r;
1622  }
1623 
1624  return CanonicalForm( fInt );
1625  }
1626  else
1627  // we do not go for maximal speed for these stupid
1628  // special cases
1629  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1630  }
1631  else if ( what )
1632  return f.value->bgcdcoeff( g.value );
1633 
1634  int fLevel = f.value->level();
1635  int gLevel = g.value->level();
1636 
1637  // check levels
1638  if ( fLevel == gLevel )
1639  {
1640  fLevel = f.value->levelcoeff();
1641  gLevel = g.value->levelcoeff();
1642 
1643  // check levelcoeffs
1644  if ( fLevel == gLevel )
1645  return f.value->bgcdsame( g.value );
1646  else if ( fLevel < gLevel )
1647  return g.value->bgcdcoeff( f.value );
1648  else
1649  return f.value->bgcdcoeff( g.value );
1650  }
1651  else if ( fLevel < gLevel )
1652  return g.value->bgcdcoeff( f.value );
1653  else
1654  return f.value->bgcdcoeff( g.value );
1655 }

◆ bgcd [2/3]

CanonicalForm bgcd ( const CanonicalForm f,
const CanonicalForm g 
)
friend

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

bgcd() - return base coefficient gcd.

If both f and g are integers and ‘SW_RATIONAL’ is off the positive greatest common divisor of f and g is returned. Otherwise, if ‘SW_RATIONAL’ is on or one of f and g is not an integer, the greatest common divisor is trivial: either zero if f and g equal zero or one (both from the current domain).

f and g should come from one base domain which should be not the prime power domain.

Implementation:

CanonicalForm::bgcd() handles the immediate case with a standard euclidean algorithm. For the non-immediate cases ‘InternalCF::bgcdsame()’ or ‘InternalCF::bgcdcoeff()’, resp. are called following the usual level/levelcoeff approach.

InternalCF::bgcdsame() and InternalCF::bgcdcoeff() throw an assertion ("not implemented")

InternalInteger::bgcdsame() is a wrapper around ‘mpz_gcd()’ which takes some care about immediate results and the sign of the result InternalInteger::bgcdcoeff() is a wrapper around ‘mpz_gcd_ui()’ which takes some care about the sign of the result

InternalRational::bgcdsame() and InternalRational::bgcdcoeff() always return one

Definition at line 1589 of file canonicalform.cc.

1590 {
1591  // check immediate cases
1592  int what = is_imm( g.value );
1593  if ( is_imm( f.value ) )
1594  {
1595  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1596  if ( what == 0 )
1597  return g.value->bgcdcoeff( f.value );
1598  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1599  {
1600  // calculate gcd using standard integer
1601  // arithmetic
1602  long fInt = imm2int( f.value );
1603  long gInt = imm2int( g.value );
1604 
1605  if ( fInt < 0 ) fInt = -fInt;
1606  if ( gInt < 0 ) gInt = -gInt;
1607  // swap fInt and gInt
1608  if ( gInt > fInt )
1609  {
1610  long swap = gInt;
1611  gInt = fInt;
1612  fInt = swap;
1613  }
1614 
1615  // now, 0 <= gInt <= fInt. Start the loop.
1616  while ( gInt )
1617  {
1618  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1619  long r = fInt % gInt;
1620  fInt = gInt;
1621  gInt = r;
1622  }
1623 
1624  return CanonicalForm( fInt );
1625  }
1626  else
1627  // we do not go for maximal speed for these stupid
1628  // special cases
1629  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1630  }
1631  else if ( what )
1632  return f.value->bgcdcoeff( g.value );
1633 
1634  int fLevel = f.value->level();
1635  int gLevel = g.value->level();
1636 
1637  // check levels
1638  if ( fLevel == gLevel )
1639  {
1640  fLevel = f.value->levelcoeff();
1641  gLevel = g.value->levelcoeff();
1642 
1643  // check levelcoeffs
1644  if ( fLevel == gLevel )
1645  return f.value->bgcdsame( g.value );
1646  else if ( fLevel < gLevel )
1647  return g.value->bgcdcoeff( f.value );
1648  else
1649  return f.value->bgcdcoeff( g.value );
1650  }
1651  else if ( fLevel < gLevel )
1652  return g.value->bgcdcoeff( f.value );
1653  else
1654  return f.value->bgcdcoeff( g.value );
1655 }

◆ bgcd [3/3]

CanonicalForm bgcd ( const CanonicalForm f,
const CanonicalForm g 
)
friend

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

bgcd() - return base coefficient gcd.

If both f and g are integers and ‘SW_RATIONAL’ is off the positive greatest common divisor of f and g is returned. Otherwise, if ‘SW_RATIONAL’ is on or one of f and g is not an integer, the greatest common divisor is trivial: either zero if f and g equal zero or one (both from the current domain).

f and g should come from one base domain which should be not the prime power domain.

Implementation:

CanonicalForm::bgcd() handles the immediate case with a standard euclidean algorithm. For the non-immediate cases ‘InternalCF::bgcdsame()’ or ‘InternalCF::bgcdcoeff()’, resp. are called following the usual level/levelcoeff approach.

InternalCF::bgcdsame() and InternalCF::bgcdcoeff() throw an assertion ("not implemented")

InternalInteger::bgcdsame() is a wrapper around ‘mpz_gcd()’ which takes some care about immediate results and the sign of the result InternalInteger::bgcdcoeff() is a wrapper around ‘mpz_gcd_ui()’ which takes some care about the sign of the result

InternalRational::bgcdsame() and InternalRational::bgcdcoeff() always return one

Definition at line 1589 of file canonicalform.cc.

1590 {
1591  // check immediate cases
1592  int what = is_imm( g.value );
1593  if ( is_imm( f.value ) )
1594  {
1595  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1596  if ( what == 0 )
1597  return g.value->bgcdcoeff( f.value );
1598  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1599  {
1600  // calculate gcd using standard integer
1601  // arithmetic
1602  long fInt = imm2int( f.value );
1603  long gInt = imm2int( g.value );
1604 
1605  if ( fInt < 0 ) fInt = -fInt;
1606  if ( gInt < 0 ) gInt = -gInt;
1607  // swap fInt and gInt
1608  if ( gInt > fInt )
1609  {
1610  long swap = gInt;
1611  gInt = fInt;
1612  fInt = swap;
1613  }
1614 
1615  // now, 0 <= gInt <= fInt. Start the loop.
1616  while ( gInt )
1617  {
1618  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1619  long r = fInt % gInt;
1620  fInt = gInt;
1621  gInt = r;
1622  }
1623 
1624  return CanonicalForm( fInt );
1625  }
1626  else
1627  // we do not go for maximal speed for these stupid
1628  // special cases
1629  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1630  }
1631  else if ( what )
1632  return f.value->bgcdcoeff( g.value );
1633 
1634  int fLevel = f.value->level();
1635  int gLevel = g.value->level();
1636 
1637  // check levels
1638  if ( fLevel == gLevel )
1639  {
1640  fLevel = f.value->levelcoeff();
1641  gLevel = g.value->levelcoeff();
1642 
1643  // check levelcoeffs
1644  if ( fLevel == gLevel )
1645  return f.value->bgcdsame( g.value );
1646  else if ( fLevel < gLevel )
1647  return g.value->bgcdcoeff( f.value );
1648  else
1649  return f.value->bgcdcoeff( g.value );
1650  }
1651  else if ( fLevel < gLevel )
1652  return g.value->bgcdcoeff( f.value );
1653  else
1654  return f.value->bgcdcoeff( g.value );
1655 }

◆ CFIterator

CFIterator
friend

Definition at line 199 of file canonicalform.h.

◆ divrem [1/3]

void divrem ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 967 of file canonicalform.cc.

968 {
969  InternalCF * qq = 0, * rr = 0;
970  int what = is_imm( f.value );
971  if ( what )
972  if ( is_imm( g.value ) ) {
973  if ( what == FFMARK )
974  imm_divrem_p( f.value, g.value, qq, rr );
975  else if ( what == GFMARK )
976  imm_divrem_gf( f.value, g.value, qq, rr );
977  else
978  imm_divrem( f.value, g.value, qq, rr );
979  }
980  else
981  g.value->divremcoeff( f.value, qq, rr, true );
982  else if ( (what=is_imm( g.value )) )
983  f.value->divremcoeff( g.value, qq, rr, false );
984  else if ( f.value->level() == g.value->level() )
985  if ( f.value->levelcoeff() == g.value->levelcoeff() )
986  f.value->divremsame( g.value, qq, rr );
987  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
988  f.value->divremcoeff( g.value, qq, rr, false );
989  else
990  g.value->divremcoeff( f.value, qq, rr, true );
991  else if ( f.value->level() > g.value->level() )
992  f.value->divremcoeff( g.value, qq, rr, false );
993  else
994  g.value->divremcoeff( f.value, qq, rr, true );
995  ASSERT( qq != 0 && rr != 0, "error in divrem" );
996  q = CanonicalForm( qq );
997  r = CanonicalForm( rr );
998 }

◆ divrem [2/3]

void divrem ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 967 of file canonicalform.cc.

968 {
969  InternalCF * qq = 0, * rr = 0;
970  int what = is_imm( f.value );
971  if ( what )
972  if ( is_imm( g.value ) ) {
973  if ( what == FFMARK )
974  imm_divrem_p( f.value, g.value, qq, rr );
975  else if ( what == GFMARK )
976  imm_divrem_gf( f.value, g.value, qq, rr );
977  else
978  imm_divrem( f.value, g.value, qq, rr );
979  }
980  else
981  g.value->divremcoeff( f.value, qq, rr, true );
982  else if ( (what=is_imm( g.value )) )
983  f.value->divremcoeff( g.value, qq, rr, false );
984  else if ( f.value->level() == g.value->level() )
985  if ( f.value->levelcoeff() == g.value->levelcoeff() )
986  f.value->divremsame( g.value, qq, rr );
987  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
988  f.value->divremcoeff( g.value, qq, rr, false );
989  else
990  g.value->divremcoeff( f.value, qq, rr, true );
991  else if ( f.value->level() > g.value->level() )
992  f.value->divremcoeff( g.value, qq, rr, false );
993  else
994  g.value->divremcoeff( f.value, qq, rr, true );
995  ASSERT( qq != 0 && rr != 0, "error in divrem" );
996  q = CanonicalForm( qq );
997  r = CanonicalForm( rr );
998 }

◆ divrem [3/3]

void divrem ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 967 of file canonicalform.cc.

968 {
969  InternalCF * qq = 0, * rr = 0;
970  int what = is_imm( f.value );
971  if ( what )
972  if ( is_imm( g.value ) ) {
973  if ( what == FFMARK )
974  imm_divrem_p( f.value, g.value, qq, rr );
975  else if ( what == GFMARK )
976  imm_divrem_gf( f.value, g.value, qq, rr );
977  else
978  imm_divrem( f.value, g.value, qq, rr );
979  }
980  else
981  g.value->divremcoeff( f.value, qq, rr, true );
982  else if ( (what=is_imm( g.value )) )
983  f.value->divremcoeff( g.value, qq, rr, false );
984  else if ( f.value->level() == g.value->level() )
985  if ( f.value->levelcoeff() == g.value->levelcoeff() )
986  f.value->divremsame( g.value, qq, rr );
987  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
988  f.value->divremcoeff( g.value, qq, rr, false );
989  else
990  g.value->divremcoeff( f.value, qq, rr, true );
991  else if ( f.value->level() > g.value->level() )
992  f.value->divremcoeff( g.value, qq, rr, false );
993  else
994  g.value->divremcoeff( f.value, qq, rr, true );
995  ASSERT( qq != 0 && rr != 0, "error in divrem" );
996  q = CanonicalForm( qq );
997  r = CanonicalForm( rr );
998 }

◆ divremt [1/3]

bool divremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 1001 of file canonicalform.cc.

1002 {
1003  InternalCF * qq = 0, * rr = 0;
1004  int what = is_imm( f.value );
1005  bool result = true;
1006  if ( what )
1007  if ( is_imm( g.value ) ) {
1008  if ( what == FFMARK )
1009  imm_divrem_p( f.value, g.value, qq, rr );
1010  else if ( what == GFMARK )
1011  imm_divrem_gf( f.value, g.value, qq, rr );
1012  else
1013  imm_divrem( f.value, g.value, qq, rr );
1014  }
1015  else
1016  result = g.value->divremcoefft( f.value, qq, rr, true );
1017  else if ( (what=is_imm( g.value )) )
1018  result = f.value->divremcoefft( g.value, qq, rr, false );
1019  else if ( f.value->level() == g.value->level() )
1020  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1021  result = f.value->divremsamet( g.value, qq, rr );
1022  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1023  result = f.value->divremcoefft( g.value, qq, rr, false );
1024  else
1025  result = g.value->divremcoefft( f.value, qq, rr, true );
1026  else if ( f.value->level() > g.value->level() )
1027  result = f.value->divremcoefft( g.value, qq, rr, false );
1028  else
1029  result = g.value->divremcoefft( f.value, qq, rr, true );
1030  if ( result ) {
1031  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1032  q = CanonicalForm( qq );
1033  r = CanonicalForm( rr );
1034  }
1035  else {
1036  q = 0; r = 0;
1037  }
1038  return result;
1039 }

◆ divremt [2/3]

bool divremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 1001 of file canonicalform.cc.

1002 {
1003  InternalCF * qq = 0, * rr = 0;
1004  int what = is_imm( f.value );
1005  bool result = true;
1006  if ( what )
1007  if ( is_imm( g.value ) ) {
1008  if ( what == FFMARK )
1009  imm_divrem_p( f.value, g.value, qq, rr );
1010  else if ( what == GFMARK )
1011  imm_divrem_gf( f.value, g.value, qq, rr );
1012  else
1013  imm_divrem( f.value, g.value, qq, rr );
1014  }
1015  else
1016  result = g.value->divremcoefft( f.value, qq, rr, true );
1017  else if ( (what=is_imm( g.value )) )
1018  result = f.value->divremcoefft( g.value, qq, rr, false );
1019  else if ( f.value->level() == g.value->level() )
1020  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1021  result = f.value->divremsamet( g.value, qq, rr );
1022  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1023  result = f.value->divremcoefft( g.value, qq, rr, false );
1024  else
1025  result = g.value->divremcoefft( f.value, qq, rr, true );
1026  else if ( f.value->level() > g.value->level() )
1027  result = f.value->divremcoefft( g.value, qq, rr, false );
1028  else
1029  result = g.value->divremcoefft( f.value, qq, rr, true );
1030  if ( result ) {
1031  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1032  q = CanonicalForm( qq );
1033  r = CanonicalForm( rr );
1034  }
1035  else {
1036  q = 0; r = 0;
1037  }
1038  return result;
1039 }

◆ divremt [3/3]

bool divremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r 
)
friend

Definition at line 1001 of file canonicalform.cc.

1002 {
1003  InternalCF * qq = 0, * rr = 0;
1004  int what = is_imm( f.value );
1005  bool result = true;
1006  if ( what )
1007  if ( is_imm( g.value ) ) {
1008  if ( what == FFMARK )
1009  imm_divrem_p( f.value, g.value, qq, rr );
1010  else if ( what == GFMARK )
1011  imm_divrem_gf( f.value, g.value, qq, rr );
1012  else
1013  imm_divrem( f.value, g.value, qq, rr );
1014  }
1015  else
1016  result = g.value->divremcoefft( f.value, qq, rr, true );
1017  else if ( (what=is_imm( g.value )) )
1018  result = f.value->divremcoefft( g.value, qq, rr, false );
1019  else if ( f.value->level() == g.value->level() )
1020  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1021  result = f.value->divremsamet( g.value, qq, rr );
1022  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1023  result = f.value->divremcoefft( g.value, qq, rr, false );
1024  else
1025  result = g.value->divremcoefft( f.value, qq, rr, true );
1026  else if ( f.value->level() > g.value->level() )
1027  result = f.value->divremcoefft( g.value, qq, rr, false );
1028  else
1029  result = g.value->divremcoefft( f.value, qq, rr, true );
1030  if ( result ) {
1031  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1032  q = CanonicalForm( qq );
1033  r = CanonicalForm( rr );
1034  }
1035  else {
1036  q = 0; r = 0;
1037  }
1038  return result;
1039 }

◆ operator!= [1/3]

bool operator!= ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator !=() returns true iff lhs does not equal rhs.

See also
CanonicalForm::operator ==()

Definition at line 1433 of file canonicalform.cc.

1434 {
1435  if ( lhs.value == rhs.value )
1436  return false;
1437  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1438  ASSERT( ! is_imm( rhs.value ) ||
1439  ! is_imm( lhs.value ) ||
1440  is_imm( rhs.value ) == is_imm( lhs.value ),
1441  "incompatible operands" );
1442  return true;
1443  }
1444  else if ( lhs.value->level() != rhs.value->level() )
1445  return true;
1446  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1447  return true;
1448  else return rhs.value->comparesame( lhs.value ) != 0;
1449 }

◆ operator!= [2/3]

bool operator!= ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator !=() returns true iff lhs does not equal rhs.

See also
CanonicalForm::operator ==()

Definition at line 1433 of file canonicalform.cc.

1434 {
1435  if ( lhs.value == rhs.value )
1436  return false;
1437  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1438  ASSERT( ! is_imm( rhs.value ) ||
1439  ! is_imm( lhs.value ) ||
1440  is_imm( rhs.value ) == is_imm( lhs.value ),
1441  "incompatible operands" );
1442  return true;
1443  }
1444  else if ( lhs.value->level() != rhs.value->level() )
1445  return true;
1446  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1447  return true;
1448  else return rhs.value->comparesame( lhs.value ) != 0;
1449 }

◆ operator!= [3/3]

bool operator!= ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator !=() returns true iff lhs does not equal rhs.

See also
CanonicalForm::operator ==()

Definition at line 1433 of file canonicalform.cc.

1434 {
1435  if ( lhs.value == rhs.value )
1436  return false;
1437  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1438  ASSERT( ! is_imm( rhs.value ) ||
1439  ! is_imm( lhs.value ) ||
1440  is_imm( rhs.value ) == is_imm( lhs.value ),
1441  "incompatible operands" );
1442  return true;
1443  }
1444  else if ( lhs.value->level() != rhs.value->level() )
1445  return true;
1446  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1447  return true;
1448  else return rhs.value->comparesame( lhs.value ) != 0;
1449 }

◆ operator- [1/3]

CF_NO_INLINE CanonicalForm operator- ( const CanonicalForm cf)
friend

CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf )

operator -() - return additive inverse of ‘cf’.

Returns the additive inverse of ‘cf’. One should keep in mind that to negate a canonical form a complete (deep) copy of it has to be created.

Type info:

cf: CurrentPP

In fact, the type is almost ‘Anything’, but it is, e.g., not possible to invert an element from a finite field when the characteristic of the current domain has changed.

Internal implementation:

All internal methods check whether the reference counter equals one. If so CO is negated in-place. Otherwise, a new copy of CO is created and negated.

imm_neg() Trivial.

imm_neg_p() Use ‘ff_neg()’ to negate CO.

imm_neg_gf() Use ‘gf_neg()’ to negate CO.

InternalInteger::neg() Use ‘mpz_neg()’ to negate the underlying mpi.

InternalRational::neg () Use ‘mpz_neg()’ to negate the denominator.

InternalPrimePower::neg() Subtract CO from ‘primepow’ using ‘mpz_sub’.

InternalPoly::neg() If reference counter is one use ‘negateTermList()’ to negate the terms, otherwise create a negated copy using ‘copyTermList()’.

See also
CanonicalForm::operator -=()

Definition at line 438 of file cf_inline.cc.

439 {
441  int what = is_imm( result.value );
442 
443  if ( ! what )
444  result.value = result.value->neg();
445  else if ( what == INTMARK )
446  result.value = imm_neg( result.value );
447  else if ( what == FFMARK )
448  result.value = imm_neg_p( result.value );
449  else
450  result.value = imm_neg_gf( result.value );
451 
452  return result;
453 }

◆ operator- [2/3]

CF_NO_INLINE CanonicalForm operator- ( const CanonicalForm cf)
friend

CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf )

operator -() - return additive inverse of ‘cf’.

Returns the additive inverse of ‘cf’. One should keep in mind that to negate a canonical form a complete (deep) copy of it has to be created.

Type info:

cf: CurrentPP

In fact, the type is almost ‘Anything’, but it is, e.g., not possible to invert an element from a finite field when the characteristic of the current domain has changed.

Internal implementation:

All internal methods check whether the reference counter equals one. If so CO is negated in-place. Otherwise, a new copy of CO is created and negated.

imm_neg() Trivial.

imm_neg_p() Use ‘ff_neg()’ to negate CO.

imm_neg_gf() Use ‘gf_neg()’ to negate CO.

InternalInteger::neg() Use ‘mpz_neg()’ to negate the underlying mpi.

InternalRational::neg () Use ‘mpz_neg()’ to negate the denominator.

InternalPrimePower::neg() Subtract CO from ‘primepow’ using ‘mpz_sub’.

InternalPoly::neg() If reference counter is one use ‘negateTermList()’ to negate the terms, otherwise create a negated copy using ‘copyTermList()’.

See also
CanonicalForm::operator -=()

Definition at line 438 of file cf_inline.cc.

439 {
441  int what = is_imm( result.value );
442 
443  if ( ! what )
444  result.value = result.value->neg();
445  else if ( what == INTMARK )
446  result.value = imm_neg( result.value );
447  else if ( what == FFMARK )
448  result.value = imm_neg_p( result.value );
449  else
450  result.value = imm_neg_gf( result.value );
451 
452  return result;
453 }

◆ operator- [3/3]

CF_NO_INLINE CanonicalForm operator- ( const CanonicalForm cf)
friend

CF_INLINE CanonicalForm operator - ( const CanonicalForm & cf )

operator -() - return additive inverse of ‘cf’.

Returns the additive inverse of ‘cf’. One should keep in mind that to negate a canonical form a complete (deep) copy of it has to be created.

Type info:

cf: CurrentPP

In fact, the type is almost ‘Anything’, but it is, e.g., not possible to invert an element from a finite field when the characteristic of the current domain has changed.

Internal implementation:

All internal methods check whether the reference counter equals one. If so CO is negated in-place. Otherwise, a new copy of CO is created and negated.

imm_neg() Trivial.

imm_neg_p() Use ‘ff_neg()’ to negate CO.

imm_neg_gf() Use ‘gf_neg()’ to negate CO.

InternalInteger::neg() Use ‘mpz_neg()’ to negate the underlying mpi.

InternalRational::neg () Use ‘mpz_neg()’ to negate the denominator.

InternalPrimePower::neg() Subtract CO from ‘primepow’ using ‘mpz_sub’.

InternalPoly::neg() If reference counter is one use ‘negateTermList()’ to negate the terms, otherwise create a negated copy using ‘copyTermList()’.

See also
CanonicalForm::operator -=()

Definition at line 438 of file cf_inline.cc.

439 {
441  int what = is_imm( result.value );
442 
443  if ( ! what )
444  result.value = result.value->neg();
445  else if ( what == INTMARK )
446  result.value = imm_neg( result.value );
447  else if ( what == FFMARK )
448  result.value = imm_neg_p( result.value );
449  else
450  result.value = imm_neg_gf( result.value );
451 
452  return result;
453 }

◆ operator< [1/3]

bool operator< ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend
See also
CanonicalForm::operator >()

Definition at line 1526 of file canonicalform.cc.

1528 {
1529  int what = is_imm( rhs.value );
1530  if ( is_imm( lhs.value ) ) {
1531  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1532  if ( what == 0 )
1533  return rhs.value->comparecoeff( lhs.value ) > 0;
1534  else if ( what == INTMARK )
1535  return imm_cmp( lhs.value, rhs.value ) < 0;
1536  else if ( what == FFMARK )
1537  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1538  else
1539  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1540  }
1541  else if ( what )
1542  return lhs.value->comparecoeff( rhs.value ) < 0;
1543  else if ( lhs.value->level() == rhs.value->level() )
1544  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1545  return lhs.value->comparesame( rhs.value ) < 0;
1546  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1547  return lhs.value->comparecoeff( rhs.value ) < 0;
1548  else
1549  return rhs.value->comparecoeff( lhs.value ) > 0;
1550  else
1551  return lhs.value->level() < rhs.value->level();
1552 }

◆ operator< [2/3]

bool operator< ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend
See also
CanonicalForm::operator >()

Definition at line 1526 of file canonicalform.cc.

1528 {
1529  int what = is_imm( rhs.value );
1530  if ( is_imm( lhs.value ) ) {
1531  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1532  if ( what == 0 )
1533  return rhs.value->comparecoeff( lhs.value ) > 0;
1534  else if ( what == INTMARK )
1535  return imm_cmp( lhs.value, rhs.value ) < 0;
1536  else if ( what == FFMARK )
1537  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1538  else
1539  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1540  }
1541  else if ( what )
1542  return lhs.value->comparecoeff( rhs.value ) < 0;
1543  else if ( lhs.value->level() == rhs.value->level() )
1544  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1545  return lhs.value->comparesame( rhs.value ) < 0;
1546  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1547  return lhs.value->comparecoeff( rhs.value ) < 0;
1548  else
1549  return rhs.value->comparecoeff( lhs.value ) > 0;
1550  else
1551  return lhs.value->level() < rhs.value->level();
1552 }

◆ operator< [3/3]

bool operator< ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend
See also
CanonicalForm::operator >()

Definition at line 1526 of file canonicalform.cc.

1528 {
1529  int what = is_imm( rhs.value );
1530  if ( is_imm( lhs.value ) ) {
1531  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1532  if ( what == 0 )
1533  return rhs.value->comparecoeff( lhs.value ) > 0;
1534  else if ( what == INTMARK )
1535  return imm_cmp( lhs.value, rhs.value ) < 0;
1536  else if ( what == FFMARK )
1537  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1538  else
1539  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1540  }
1541  else if ( what )
1542  return lhs.value->comparecoeff( rhs.value ) < 0;
1543  else if ( lhs.value->level() == rhs.value->level() )
1544  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1545  return lhs.value->comparesame( rhs.value ) < 0;
1546  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1547  return lhs.value->comparecoeff( rhs.value ) < 0;
1548  else
1549  return rhs.value->comparecoeff( lhs.value ) > 0;
1550  else
1551  return lhs.value->level() < rhs.value->level();
1552 }

◆ operator<< [1/3]

OSTREAM& operator<< ( OSTREAM os,
const CanonicalForm cf 
)
friend

Definition at line 1791 of file canonicalform.cc.

1793 {
1794  cf.print( os, "" );
1795  return os;
1796 }

◆ operator<< [2/3]

OSTREAM& operator<< ( OSTREAM os,
const CanonicalForm cf 
)
friend

Definition at line 1791 of file canonicalform.cc.

1793 {
1794  cf.print( os, "" );
1795  return os;
1796 }

◆ operator<< [3/3]

OSTREAM& operator<< ( OSTREAM os,
const CanonicalForm cf 
)
friend

Definition at line 1791 of file canonicalform.cc.

1793 {
1794  cf.print( os, "" );
1795  return os;
1796 }

◆ operator== [1/3]

bool operator== ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator ==() - compare canonical forms on (in)equality.

operator ==() returns true iff lhs equals rhs.

This is the point in factory where we essentially use that CanonicalForms in fact are canonical. There must not be two different representations of the same mathematical object, otherwise, such (in)equality will not be recognized by these operators. In other word, we rely on the fact that structural different factory objects in any case represent different mathematical objects.

So we use the following procedure to test on equality (and analogously on inequality). First, we check whether lhs.value equals rhs.value. If so we are ready and return true. Second, if one of the operands is immediate, but the other one not, we return false. Third, if the operand's levels differ we return false. Fourth, if the operand's levelcoeffs differ we return false. At last, we call the corresponding internal method to compare both operands.

Both operands should have coefficients from the same base domain.

Note: To compare with the zero or the unit of the current domain, you better use the methods ‘CanonicalForm::isZero()’ or ‘CanonicalForm::isOne()’, resp., than something like ‘f == 0’, since the latter is quite a lot slower.

See also
CanonicalForm::operator !=(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame()

Definition at line 1408 of file canonicalform.cc.

1409 {
1410  if ( lhs.value == rhs.value )
1411  return true;
1412  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1413  ASSERT( ! is_imm( rhs.value ) ||
1414  ! is_imm( lhs.value ) ||
1415  is_imm( rhs.value ) == is_imm( lhs.value ),
1416  "incompatible operands" );
1417  return false;
1418  }
1419  else if ( lhs.value->level() != rhs.value->level() )
1420  return false;
1421  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1422  return false;
1423  else
1424  return rhs.value->comparesame( lhs.value ) == 0;
1425 }

◆ operator== [2/3]

bool operator== ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator ==() - compare canonical forms on (in)equality.

operator ==() returns true iff lhs equals rhs.

This is the point in factory where we essentially use that CanonicalForms in fact are canonical. There must not be two different representations of the same mathematical object, otherwise, such (in)equality will not be recognized by these operators. In other word, we rely on the fact that structural different factory objects in any case represent different mathematical objects.

So we use the following procedure to test on equality (and analogously on inequality). First, we check whether lhs.value equals rhs.value. If so we are ready and return true. Second, if one of the operands is immediate, but the other one not, we return false. Third, if the operand's levels differ we return false. Fourth, if the operand's levelcoeffs differ we return false. At last, we call the corresponding internal method to compare both operands.

Both operands should have coefficients from the same base domain.

Note: To compare with the zero or the unit of the current domain, you better use the methods ‘CanonicalForm::isZero()’ or ‘CanonicalForm::isOne()’, resp., than something like ‘f == 0’, since the latter is quite a lot slower.

See also
CanonicalForm::operator !=(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame()

Definition at line 1408 of file canonicalform.cc.

1409 {
1410  if ( lhs.value == rhs.value )
1411  return true;
1412  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1413  ASSERT( ! is_imm( rhs.value ) ||
1414  ! is_imm( lhs.value ) ||
1415  is_imm( rhs.value ) == is_imm( lhs.value ),
1416  "incompatible operands" );
1417  return false;
1418  }
1419  else if ( lhs.value->level() != rhs.value->level() )
1420  return false;
1421  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1422  return false;
1423  else
1424  return rhs.value->comparesame( lhs.value ) == 0;
1425 }

◆ operator== [3/3]

bool operator== ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator ==() - compare canonical forms on (in)equality.

operator ==() returns true iff lhs equals rhs.

This is the point in factory where we essentially use that CanonicalForms in fact are canonical. There must not be two different representations of the same mathematical object, otherwise, such (in)equality will not be recognized by these operators. In other word, we rely on the fact that structural different factory objects in any case represent different mathematical objects.

So we use the following procedure to test on equality (and analogously on inequality). First, we check whether lhs.value equals rhs.value. If so we are ready and return true. Second, if one of the operands is immediate, but the other one not, we return false. Third, if the operand's levels differ we return false. Fourth, if the operand's levelcoeffs differ we return false. At last, we call the corresponding internal method to compare both operands.

Both operands should have coefficients from the same base domain.

Note: To compare with the zero or the unit of the current domain, you better use the methods ‘CanonicalForm::isZero()’ or ‘CanonicalForm::isOne()’, resp., than something like ‘f == 0’, since the latter is quite a lot slower.

See also
CanonicalForm::operator !=(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame()

Definition at line 1408 of file canonicalform.cc.

1409 {
1410  if ( lhs.value == rhs.value )
1411  return true;
1412  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1413  ASSERT( ! is_imm( rhs.value ) ||
1414  ! is_imm( lhs.value ) ||
1415  is_imm( rhs.value ) == is_imm( lhs.value ),
1416  "incompatible operands" );
1417  return false;
1418  }
1419  else if ( lhs.value->level() != rhs.value->level() )
1420  return false;
1421  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1422  return false;
1423  else
1424  return rhs.value->comparesame( lhs.value ) == 0;
1425 }

◆ operator> [1/3]

bool operator> ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator >() - compare canonical forms.

on size or level.

The most common and most useful application of these operators is to compare two integers or rationals, of course. However, these operators are defined on all other base domains and on polynomials, too. From a mathematical point of view this may seem meaningless, since there is no ordering on finite fields or on polynomials respecting the algebraic structure. Nevertheless, from a programmer's point of view it may be sensible to order these objects, e.g. to sort them.

Therefore, the ordering defined by these operators in any case is a total ordering which fulfills the law of trichotomy.

It is clear how this is done in the case of the integers and the rationals. For finite fields, all you can say is that zero is the minimal element w.r.t. the ordering, the other elements are ordered in an arbitrary (but total!) way. For polynomials, you have an ordering derived from the lexicographical ordering of monomials. E.g. if lm(f) < lm(g) w.r.t. lexicographic ordering, then f < g. For more details, refer to the documentation of ‘InternalPoly::operator <()’.

Both operands should have coefficients from the same base domain.

The scheme how both operators are implemented is allmost the same as for the assignment operators (check for immediates, then check levels, then check levelcoeffs, then call the appropriate internal comparesame()/comparecoeff() method). For more information, confer to the overview for the arithmetic operators.

See also
CanonicalForm::operator <(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame(), InternalCF::comparecoeff(), InternalInteger::comparecoeff(), InternalRational::comparecoeff(), InternalPoly::comparecoeff(), imm_cmp(), imm_cmp_p(), imm_cmp_gf()

Definition at line 1496 of file canonicalform.cc.

1497 {
1498  int what = is_imm( rhs.value );
1499  if ( is_imm( lhs.value ) ) {
1500  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1501  if ( what == 0 )
1502  return rhs.value->comparecoeff( lhs.value ) < 0;
1503  else if ( what == INTMARK )
1504  return imm_cmp( lhs.value, rhs.value ) > 0;
1505  else if ( what == FFMARK )
1506  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1507  else
1508  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1509  }
1510  else if ( what )
1511  return lhs.value->comparecoeff( rhs.value ) > 0;
1512  else if ( lhs.value->level() == rhs.value->level() )
1513  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1514  return lhs.value->comparesame( rhs.value ) > 0;
1515  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1516  return lhs.value->comparecoeff( rhs.value ) > 0;
1517  else
1518  return rhs.value->comparecoeff( lhs.value ) < 0;
1519  else
1520  return lhs.value->level() > rhs.value->level();
1521 }

◆ operator> [2/3]

bool operator> ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator >() - compare canonical forms.

on size or level.

The most common and most useful application of these operators is to compare two integers or rationals, of course. However, these operators are defined on all other base domains and on polynomials, too. From a mathematical point of view this may seem meaningless, since there is no ordering on finite fields or on polynomials respecting the algebraic structure. Nevertheless, from a programmer's point of view it may be sensible to order these objects, e.g. to sort them.

Therefore, the ordering defined by these operators in any case is a total ordering which fulfills the law of trichotomy.

It is clear how this is done in the case of the integers and the rationals. For finite fields, all you can say is that zero is the minimal element w.r.t. the ordering, the other elements are ordered in an arbitrary (but total!) way. For polynomials, you have an ordering derived from the lexicographical ordering of monomials. E.g. if lm(f) < lm(g) w.r.t. lexicographic ordering, then f < g. For more details, refer to the documentation of ‘InternalPoly::operator <()’.

Both operands should have coefficients from the same base domain.

The scheme how both operators are implemented is allmost the same as for the assignment operators (check for immediates, then check levels, then check levelcoeffs, then call the appropriate internal comparesame()/comparecoeff() method). For more information, confer to the overview for the arithmetic operators.

See also
CanonicalForm::operator <(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame(), InternalCF::comparecoeff(), InternalInteger::comparecoeff(), InternalRational::comparecoeff(), InternalPoly::comparecoeff(), imm_cmp(), imm_cmp_p(), imm_cmp_gf()

Definition at line 1496 of file canonicalform.cc.

1497 {
1498  int what = is_imm( rhs.value );
1499  if ( is_imm( lhs.value ) ) {
1500  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1501  if ( what == 0 )
1502  return rhs.value->comparecoeff( lhs.value ) < 0;
1503  else if ( what == INTMARK )
1504  return imm_cmp( lhs.value, rhs.value ) > 0;
1505  else if ( what == FFMARK )
1506  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1507  else
1508  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1509  }
1510  else if ( what )
1511  return lhs.value->comparecoeff( rhs.value ) > 0;
1512  else if ( lhs.value->level() == rhs.value->level() )
1513  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1514  return lhs.value->comparesame( rhs.value ) > 0;
1515  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1516  return lhs.value->comparecoeff( rhs.value ) > 0;
1517  else
1518  return rhs.value->comparecoeff( lhs.value ) < 0;
1519  else
1520  return lhs.value->level() > rhs.value->level();
1521 }

◆ operator> [3/3]

bool operator> ( const CanonicalForm lhs,
const CanonicalForm rhs 
)
friend

operator >() - compare canonical forms.

on size or level.

The most common and most useful application of these operators is to compare two integers or rationals, of course. However, these operators are defined on all other base domains and on polynomials, too. From a mathematical point of view this may seem meaningless, since there is no ordering on finite fields or on polynomials respecting the algebraic structure. Nevertheless, from a programmer's point of view it may be sensible to order these objects, e.g. to sort them.

Therefore, the ordering defined by these operators in any case is a total ordering which fulfills the law of trichotomy.

It is clear how this is done in the case of the integers and the rationals. For finite fields, all you can say is that zero is the minimal element w.r.t. the ordering, the other elements are ordered in an arbitrary (but total!) way. For polynomials, you have an ordering derived from the lexicographical ordering of monomials. E.g. if lm(f) < lm(g) w.r.t. lexicographic ordering, then f < g. For more details, refer to the documentation of ‘InternalPoly::operator <()’.

Both operands should have coefficients from the same base domain.

The scheme how both operators are implemented is allmost the same as for the assignment operators (check for immediates, then check levels, then check levelcoeffs, then call the appropriate internal comparesame()/comparecoeff() method). For more information, confer to the overview for the arithmetic operators.

See also
CanonicalForm::operator <(), InternalCF::comparesame(), InternalInteger::comparesame(), InternalRational::comparesame(), InternalPoly::comparesame(), InternalCF::comparecoeff(), InternalInteger::comparecoeff(), InternalRational::comparecoeff(), InternalPoly::comparecoeff(), imm_cmp(), imm_cmp_p(), imm_cmp_gf()

Definition at line 1496 of file canonicalform.cc.

1497 {
1498  int what = is_imm( rhs.value );
1499  if ( is_imm( lhs.value ) ) {
1500  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1501  if ( what == 0 )
1502  return rhs.value->comparecoeff( lhs.value ) < 0;
1503  else if ( what == INTMARK )
1504  return imm_cmp( lhs.value, rhs.value ) > 0;
1505  else if ( what == FFMARK )
1506  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1507  else
1508  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1509  }
1510  else if ( what )
1511  return lhs.value->comparecoeff( rhs.value ) > 0;
1512  else if ( lhs.value->level() == rhs.value->level() )
1513  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1514  return lhs.value->comparesame( rhs.value ) > 0;
1515  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1516  return lhs.value->comparecoeff( rhs.value ) > 0;
1517  else
1518  return rhs.value->comparecoeff( lhs.value ) < 0;
1519  else
1520  return lhs.value->level() > rhs.value->level();
1521 }

◆ operator>> [1/3]

ISTREAM& operator>> ( ISTREAM is,
CanonicalForm cf 
)
friend

Definition at line 1799 of file canonicalform.cc.

1800 {
1801  cf = readCF( is );
1802  return is;
1803 }

◆ operator>> [2/3]

ISTREAM& operator>> ( ISTREAM is,
CanonicalForm cf 
)
friend

Definition at line 1799 of file canonicalform.cc.

1800 {
1801  cf = readCF( is );
1802  return is;
1803 }

◆ operator>> [3/3]

ISTREAM& operator>> ( ISTREAM is,
CanonicalForm cf 
)
friend

Definition at line 1799 of file canonicalform.cc.

1800 {
1801  cf = readCF( is );
1802  return is;
1803 }

◆ tryDivremt [1/3]

bool tryDivremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r,
const CanonicalForm M,
bool &  fail 
)
friend

same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible

Definition at line 1043 of file canonicalform.cc.

1044 {
1045  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1046  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1047  fail= false;
1048  InternalCF * qq = 0, * rr = 0;
1049  int what = is_imm( f.value );
1050  bool result = true;
1051  if ( what )
1052  if ( is_imm( g.value ) ) {
1053  if ( what == FFMARK )
1054  imm_divrem_p( f.value, g.value, qq, rr );
1055  else if ( what == GFMARK )
1056  imm_divrem_gf( f.value, g.value, qq, rr );
1057  }
1058  else
1059  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1060  else if ( (what=is_imm( g.value )) )
1061  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1062  else if ( f.value->level() == g.value->level() )
1063  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1064  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1065  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1066  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1067  else
1068  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1069  else if ( f.value->level() > g.value->level() )
1070  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1071  else
1072  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1073  if (fail)
1074  {
1075  q= 0;
1076  r= 0;
1077  return false;
1078  }
1079  if ( result ) {
1080  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1081  q = CanonicalForm( qq );
1082  r = CanonicalForm( rr );
1083  q= reduce (q, M);
1084  r= reduce (r, M);
1085  }
1086  else {
1087  q = 0; r = 0;
1088  }
1089  return result;
1090 }

◆ tryDivremt [2/3]

bool tryDivremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r,
const CanonicalForm M,
bool &  fail 
)
friend

same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible

Definition at line 1043 of file canonicalform.cc.

1044 {
1045  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1046  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1047  fail= false;
1048  InternalCF * qq = 0, * rr = 0;
1049  int what = is_imm( f.value );
1050  bool result = true;
1051  if ( what )
1052  if ( is_imm( g.value ) ) {
1053  if ( what == FFMARK )
1054  imm_divrem_p( f.value, g.value, qq, rr );
1055  else if ( what == GFMARK )
1056  imm_divrem_gf( f.value, g.value, qq, rr );
1057  }
1058  else
1059  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1060  else if ( (what=is_imm( g.value )) )
1061  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1062  else if ( f.value->level() == g.value->level() )
1063  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1064  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1065  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1066  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1067  else
1068  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1069  else if ( f.value->level() > g.value->level() )
1070  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1071  else
1072  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1073  if (fail)
1074  {
1075  q= 0;
1076  r= 0;
1077  return false;
1078  }
1079  if ( result ) {
1080  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1081  q = CanonicalForm( qq );
1082  r = CanonicalForm( rr );
1083  q= reduce (q, M);
1084  r= reduce (r, M);
1085  }
1086  else {
1087  q = 0; r = 0;
1088  }
1089  return result;
1090 }

◆ tryDivremt [3/3]

bool tryDivremt ( const CanonicalForm f,
const CanonicalForm g,
CanonicalForm q,
CanonicalForm r,
const CanonicalForm M,
bool &  fail 
)
friend

same as divremt but handles zero divisors in case we are in Z_p[x]/(f) where f is not irreducible

Definition at line 1043 of file canonicalform.cc.

1044 {
1045  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1046  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1047  fail= false;
1048  InternalCF * qq = 0, * rr = 0;
1049  int what = is_imm( f.value );
1050  bool result = true;
1051  if ( what )
1052  if ( is_imm( g.value ) ) {
1053  if ( what == FFMARK )
1054  imm_divrem_p( f.value, g.value, qq, rr );
1055  else if ( what == GFMARK )
1056  imm_divrem_gf( f.value, g.value, qq, rr );
1057  }
1058  else
1059  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1060  else if ( (what=is_imm( g.value )) )
1061  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1062  else if ( f.value->level() == g.value->level() )
1063  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1064  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1065  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1066  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1067  else
1068  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1069  else if ( f.value->level() > g.value->level() )
1070  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1071  else
1072  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1073  if (fail)
1074  {
1075  q= 0;
1076  r= 0;
1077  return false;
1078  }
1079  if ( result ) {
1080  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1081  q = CanonicalForm( qq );
1082  r = CanonicalForm( rr );
1083  q= reduce (q, M);
1084  r= reduce (r, M);
1085  }
1086  else {
1087  q = 0; r = 0;
1088  }
1089  return result;
1090 }

Field Documentation

◆ value

InternalCF * CanonicalForm::value
private

Definition at line 85 of file canonicalform.h.


The documentation for this class was generated from the following files:
CFFactory::poly
static InternalCF * poly(const Variable &v, int exp, const CanonicalForm &c)
Definition: cf_factory.cc:243
InternalCF::intval
virtual long intval() const
Definition: int_cf.cc:165
InternalCF::degree
virtual int degree()
int InternalCF::degree ()
Definition: int_cf.cc:55
GFMARK
const long GFMARK
Definition: imm.h:39
InternalCF::mulsame
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")
CanonicalForm::print
void print(OSTREAM &, char *) const
input/output
Definition: canonicalform.cc:1774
imm_add_p
InternalCF * imm_add_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:278
SW_RATIONAL
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
imm_mod
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:394
imm_mul
InternalCF * imm_mul(InternalCF *lhs, InternalCF *rhs)
Definition: imm.h:308
imm_print
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
Definition: imm.h:476
f
FILE * f
Definition: checklibs.c:9
InternalCF::inBaseDomain
virtual bool inBaseDomain() const
Definition: int_cf.h:74
getmpi
void getmpi(InternalCF *value, mpz_t mpi)
Definition: cf_factory.cc:260
CFIterator
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
x
Variable x
Definition: cfModGcd.cc:4023
y
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
result
return result
Definition: facAbsBiFact.cc:76
RationalDomain
#define RationalDomain
Definition: cf_defs.h:24
imm_mul_gf
InternalCF * imm_mul_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:351
InternalCF::modulosame
virtual InternalCF * modulosame(InternalCF *) PVIRT_INTCF("modulosame")
InternalCF::divsame
virtual InternalCF * divsame(InternalCF *) PVIRT_INTCF("divsame")
CxxTest::base
char N base
Definition: ValueTraits.h:144
CFFactory::gettype
static int gettype()
Definition: cf_factory.h:28
cf
CanonicalForm cf
Definition: cfModGcd.cc:4024
InternalCF::isZero
virtual bool isZero() const
Definition: int_cf.cc:24
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:646
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition: canonicalform.cc:1837
imm_divrem_gf
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:446
g
g
Definition: cfModGcd.cc:4031
is_imm
int is_imm(const InternalCF *const ptr)
Definition: factory.h:206
InternalCF::tailcoeff
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
Definition: int_cf.cc:67
InternalCF::subsame
virtual InternalCF * subsame(InternalCF *) PVIRT_INTCF("subsame")
InternalCF::taildegree
virtual int taildegree()
Definition: int_cf.cc:73
InternalCF
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
InternalCF::addsame
virtual InternalCF * addsame(InternalCF *) PVIRT_INTCF("addsame")
imm_neg_gf
InternalCF * imm_neg_gf(const InternalCF *const op)
Definition: imm.h:467
InternalCF::intmod
virtual int intmod(int) const
Definition: int_cf.h:83
InternalCF::comparesame
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
InternalCF::genZero
virtual InternalCF * genZero() PVIRT_INTCF("genZero")
getCharacteristic
int getCharacteristic()
Definition: cf_char.cc:51
b
CanonicalForm b
Definition: cfModGcd.cc:4044
InternalCF::isOne
virtual bool isOne() const
bool InternalCF::isOne, isZero () const
Definition: int_cf.cc:18
CanonicalForm::num
CanonicalForm num() const
num() returns the numerator of CO if CO is a rational number, CO itself otherwise.
Definition: canonicalform.cc:578
imm_neg_p
InternalCF * imm_neg_p(const InternalCF *const op)
Definition: imm.h:461
CanonicalForm
factory's main class
Definition: canonicalform.h:83
CanonicalForm::value
InternalCF * value
Definition: canonicalform.h:85
ff_symmetric
int ff_symmetric(const int a)
Definition: ffops.h:67
InternalCF::subcoeff
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
InternalCF::print
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
InternalCF::copyObject
InternalCF * copyObject()
Definition: int_cf.h:62
gf_gf2ff
long gf_gf2ff(long a)
Definition: gfops.cc:226
InternalCF::level
virtual int level() const
Definition: int_cf.h:67
GaloisFieldDomain
#define GaloisFieldDomain
Definition: cf_defs.h:22
i
int i
Definition: cfEzgcd.cc:125
imm_div_p
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:384
swapvar
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
InternalCF::levelcoeff
virtual int levelcoeff() const
Definition: int_cf.h:68
mulNTL
CanonicalForm mulNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f),...
Definition: facMul.cc:407
ASSERT
#define ASSERT(expression, message)
Definition: cf_assert.h:99
INTMARK
const long INTMARK
Definition: imm.h:37
M
#define M
Definition: sirandom.c:24
FFMARK
const long FFMARK
Definition: imm.h:38
int2imm
static InternalCF * int2imm(long i)
Definition: imm.h:75
InternalCF::isUnivariate
virtual bool isUnivariate() const
Definition: int_cf.h:81
InternalCF::addcoeff
virtual InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
imm_sign
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
Definition: imm.h:197
imm_divrem
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:428
InternalCF::LC
virtual CanonicalForm LC()
Definition: int_cf.cc:46
gf_isff
bool gf_isff(long a)
Definition: gfops.cc:270
CanonicalForm::deriv
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.
Definition: canonicalform.cc:1235
imm_cmp_gf
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:256
CFFactory::basic
static InternalCF * basic(long value)
Definition: cf_factory.cc:30
gInt
static long gInt(number &a, const coeffs)
Definition: generics.cc:148
InternalCF::inCoeffDomain
virtual bool inCoeffDomain() const
Definition: int_cf.h:76
InternalCF::coeff
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
Definition: int_cf.cc:120
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
InternalCF::sqrt
virtual InternalCF * sqrt()
InternalCF * InternalCF::sqrt ()
Definition: int_cf.cc:100
CanonicalForm::CanonicalForm
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
imm_isone
int imm_isone(const InternalCF *const ptr)
Definition: imm.h:124
InternalCF::modcoeff
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
imm_sub_p
InternalCF * imm_sub_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:297
divNTL
CanonicalForm divNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
division of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z,...
Definition: facMul.cc:850
imm_add
InternalCF * imm_add(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:269
InternalCF::genOne
virtual InternalCF * genOne() PVIRT_INTCF("genOne")
FiniteFieldDomain
#define FiniteFieldDomain
Definition: cf_defs.h:23
imm_cmp
int imm_cmp(const InternalCF *const lhs, const InternalCF *const rhs)
imm_cmp(), imm_cmp_p(), imm_cmp_gf() - compare immediate objects.
Definition: imm.h:234
Variable::level
int level() const
Definition: factory.h:134
imm_mod_gf
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
Definition: imm.h:423
InternalCF::Lc
virtual CanonicalForm Lc()
Definition: int_cf.cc:40
InternalCF::tryDivcoeff
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_cf.cc:214
imm_iszero_p
int imm_iszero_p(const InternalCF *const ptr)
Definition: imm.h:151
InternalCF::variable
virtual Variable variable() const
Definition: int_cf.h:70
imm_divrem_p
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:440
imm_sub_gf
InternalCF * imm_sub_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:302
InternalCF::dividecoeff
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
CanonicalForm::den
CanonicalForm den() const
den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!...
Definition: canonicalform.cc:595
InternalCF::comparecoeff
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
InternalCF::den
virtual InternalCF * den()
Definition: int_cf.cc:91
List::getFirst
T getFirst() const
Definition: ftmpl_list.cc:279
getGFDegree
int getGFDegree()
Definition: cf_char.cc:56
get_Terms
CFList get_Terms(const CanonicalForm &f)
Definition: cf_factor.cc:274
readCF
CanonicalForm readCF(ISTREAM &)
Definition: readcf.cc:1505
InternalCF::deleteObject
int deleteObject()
Definition: int_cf.h:61
LEVELBASE
#define LEVELBASE
Definition: cf_defs.h:16
imm_iszero_gf
int imm_iszero_gf(const InternalCF *const ptr)
Definition: imm.h:157
CanonicalForm::inCoeffDomain
bool inCoeffDomain() const
Definition: canonicalform.cc:119
imm_mul_p
InternalCF * imm_mul_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:346
InternalCF::dividesame
virtual InternalCF * dividesame(InternalCF *) PVIRT_INTCF("dividesame")
imm_cmp_p
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:245
imm_divrat
InternalCF * imm_divrat(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:368
InternalCF::tryDivsame
virtual InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_cf.cc:207
imm2int
static long imm2int(const InternalCF *const imm)
Definition: imm.h:70
Variable
factory's class for variables
Definition: factory.h:118
CanonicalForm::degree
int degree() const
Returns -1 for the zero polynomial and 0 if CO is in a base domain.
Definition: canonicalform.cc:381
imm_iszero
int imm_iszero(const InternalCF *const ptr)
Definition: imm.h:145
InternalCF::inQuotDomain
virtual bool inQuotDomain() const
Definition: int_cf.h:78
InternalCF::modulocoeff
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
InternalCF::inExtension
virtual bool inExtension() const
Definition: int_cf.h:75
is_imm
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:62
InternalCF::divcoeff
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
cf_glob_switches
CFSwitches cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.cc:41
int2imm_p
InternalCF * int2imm_p(long i)
Definition: imm.h:101
imm_add_gf
InternalCF * imm_add_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:283
imm_div
InternalCF * imm_div(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:356
imm_isone_gf
int imm_isone_gf(const InternalCF *const ptr)
Definition: imm.h:136
ff_norm
int ff_norm(const int a)
Definition: ffops.h:39
InternalCF::inPolyDomain
virtual bool inPolyDomain() const
Definition: int_cf.h:77
InternalCF::ilog2
virtual int ilog2()
int InternalCF::ilog2 ()
Definition: int_cf.cc:110
ff_prime
int ff_prime
Definition: ffops.cc:14
imm_isone_p
int imm_isone_p(const InternalCF *const ptr)
Definition: imm.h:130
InternalCF::num
virtual InternalCF * num()
InternalCF * InternalCF::num (), den ()
Definition: int_cf.cc:85
InternalCF::mulcoeff
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
CanonicalForm::isUnivariate
bool isUnivariate() const
Definition: canonicalform.cc:152
imm_neg
InternalCF * imm_neg(const InternalCF *const op)
Definition: imm.h:455
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
List< CanonicalForm >
swap
#define swap(_i, _j)
gf_int2gf
int gf_int2gf(int i)
Definition: gfops.h:65
CanonicalForm::mapinto
CanonicalForm mapinto() const
Definition: canonicalform.cc:206
CanonicalForm::isZero
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
int2imm_gf
InternalCF * int2imm_gf(long i)
Definition: imm.h:106
getReduce
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
CanonicalForm::level
int level() const
level() returns the level of CO.
Definition: canonicalform.cc:543
imm_div_gf
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:389
InternalCF::deepCopyObject
virtual InternalCF * deepCopyObject() const PVIRT_INTCF("deepCopyObject")
InternalCF::modsame
virtual InternalCF * modsame(InternalCF *) PVIRT_INTCF("modsame")
imm_sub
InternalCF * imm_sub(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:288
IntegerDomain
#define IntegerDomain
Definition: cf_defs.h:25
imm_mod_p
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
Definition: imm.h:418
totaldegree
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
imm_intval
long imm_intval(const InternalCF *const op)
Definition: imm.h:164
CFSwitches::isOn
bool isOn(int s) const
check if 's' is on
Definition: cf_switches.h:55
InternalCF::sign
virtual int sign() const PVIRT_INT("sign")
ListIterator
Definition: ftmpl_list.h:87
InternalCF::lc
virtual CanonicalForm lc()
CanonicalForm InternalCF::lc (), Lc (), LC ()
Definition: int_cf.cc:34