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

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 75 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 }
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
InternalCF * value
Definition: canonicalform.h:81

§ 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 }
InternalCF * copyObject()
Definition: int_cf.h:58
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 }
InternalCF * value
Definition: canonicalform.h:81

§ 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( (long)i ) )
146 {
147 }
int i
Definition: cfEzgcd.cc:123
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
InternalCF * value
Definition: canonicalform.h:81

§ 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 }
int i
Definition: cfEzgcd.cc:123
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
InternalCF * value
Definition: canonicalform.h:81

§ 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 }
static InternalCF * poly(const Variable &v, int exp, const CanonicalForm &c)
Definition: cf_factory.cc:238
InternalCF * value
Definition: canonicalform.h:81

§ 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 }
static InternalCF * poly(const Variable &v, int exp, const CanonicalForm &c)
Definition: cf_factory.cc:238
InternalCF * value
Definition: canonicalform.h:81

§ CanonicalForm() [8/24]

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

constructors, destructors, selectors

Definition at line 28 of file canonicalform.cc.

28  : value( CFFactory::basic( str, base ) )
29 {
30 }
char N base
Definition: ValueTraits.h:144
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
InternalCF * value
Definition: canonicalform.h:81

§ ~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 }
int deleteObject()
Definition: int_cf.h:57
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 42 of file canonicalform.cc.

43 {
44  if ( is_imm( value ) )
45  return *this;
46  else
47  return CanonicalForm( value->deepCopyObject() );
48 }
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * deepCopyObject() const PVIRT_INTCF("deepCopyObject")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 383 of file canonicalform.cc.

384 {
385  int what = is_imm( value );
386  if ( what )
387  if ( what == FFMARK )
388  return imm_iszero_p( value ) ? -1 : 0;
389  else if ( what == INTMARK )
390  return imm_iszero( value ) ? -1 : 0;
391  else
392  return imm_iszero_gf( value ) ? -1 : 0;
393  else
394  return value->degree();
395 }
int imm_iszero_p(const InternalCF *const ptr)
Definition: imm.h:147
virtual int degree()
int InternalCF::degree ()
Definition: int_cf.cc:55
const long FFMARK
Definition: imm.h:38
int imm_iszero_gf(const InternalCF *const ptr)
Definition: imm.h:153
int imm_iszero(const InternalCF *const ptr)
Definition: imm.h:141
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37

§ degree() [2/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 409 of file canonicalform.cc.

410 {
411  int what = is_imm( value );
412 #if 0
413  if ( what )
414  if ( what == FFMARK )
415  return imm_iszero_p( value ) ? -1 : 0;
416  else if ( what == INTMARK )
417  return imm_iszero( value ) ? -1 : 0;
418  else
419  return imm_iszero_gf( value ) ? -1 : 0;
420  else if ( value->inBaseDomain() )
421  return value->degree();
422 #else
423  switch(what)
424  {
425  case FFMARK: return imm_iszero_p( value ) ? -1 : 0;
426  case INTMARK: return imm_iszero( value ) ? -1 : 0;
427  case GFMARK: return imm_iszero_gf( value ) ? -1 : 0;
428  case 0: if ( value->inBaseDomain() )
429  return value->degree();
430  break;
431  }
432 #endif
433 
434  Variable x = value->variable();
435  if ( v == x )
436  return value->degree();
437  else if ( v > x )
438  // relatively to v, f is in a coefficient ring
439  return 0;
440  else {
441  int coeffdeg, result = 0;
442  // search for maximum of coefficient degree
443  for ( CFIterator i = *this; i.hasTerms(); i++ ) {
444  coeffdeg = i.coeff().degree( v );
445  if ( coeffdeg > result )
446  result = coeffdeg;
447  }
448  return result;
449  }
450 }
int imm_iszero_p(const InternalCF *const ptr)
Definition: imm.h:147
const long GFMARK
Definition: imm.h:39
virtual int degree()
int InternalCF::degree ()
Definition: int_cf.cc:55
factory&#39;s class for variables
Definition: factory.h:115
const long FFMARK
Definition: imm.h:38
int imm_iszero_gf(const InternalCF *const ptr)
Definition: imm.h:153
int imm_iszero(const InternalCF *const ptr)
Definition: imm.h:141
int i
Definition: cfEzgcd.cc:123
InternalCF * value
Definition: canonicalform.h:81
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
const long INTMARK
Definition: imm.h:37
virtual bool inBaseDomain() const
Definition: int_cf.h:70
return result
Definition: facAbsBiFact.cc:76
virtual Variable variable() const
Definition: int_cf.h:66

§ degree() [3/6]

int CanonicalForm::degree ( ) const

§ degree() [4/6]

int CanonicalForm::degree ( ) const

§ 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 597 of file canonicalform.cc.

598 {
599  if ( is_imm( value ) )
600  return CanonicalForm( 1 );
601  else
602  return CanonicalForm( value->den() );
603 }
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * den()
Definition: int_cf.cc:91
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 1237 of file canonicalform.cc.

1238 {
1239  if ( is_imm( value ) || value->inCoeffDomain() )
1240  return CanonicalForm( 0 );
1241  else {
1242  CanonicalForm result = 0;
1243  Variable x = value->variable();
1244  for ( CFIterator i = *this; i.hasTerms(); i++ )
1245  if ( i.exp() > 0 )
1246  result += power( x, i.exp()-1 ) * i.coeff() * i.exp();
1247  return result;
1248  }
1249 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
factory&#39;s class for variables
Definition: factory.h:115
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
factory&#39;s main class
Definition: canonicalform.h:75
int i
Definition: cfEzgcd.cc:123
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
return result
Definition: facAbsBiFact.cc:76
virtual Variable variable() const
Definition: int_cf.h:66

§ deriv() [2/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 1257 of file canonicalform.cc.

1258 {
1259  ASSERT( x.level() > 0, "cannot derive with respect to algebraic variables" );
1260  if ( is_imm( value ) || value->inCoeffDomain() )
1261  return CanonicalForm( 0 );
1262 
1263  Variable y = value->variable();
1264  if ( x > y )
1265  return CanonicalForm( 0 );
1266  else if ( x == y )
1267  return deriv();
1268  else {
1269  CanonicalForm result = 0;
1270  for ( CFIterator i = *this; i.hasTerms(); i++ )
1271  result += i.coeff().deriv( x ) * power( y, i.exp() );
1272  return result;
1273  }
1274 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
factory&#39;s class for variables
Definition: factory.h:115
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm deriv() const
deriv() - return the formal derivation of CO.
int level() const
Definition: factory.h:132
int i
Definition: cfEzgcd.cc:123
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76
virtual Variable variable() const
Definition: int_cf.h:66

§ deriv() [3/6]

CanonicalForm CanonicalForm::deriv ( ) const

§ deriv() [4/6]

CanonicalForm CanonicalForm::deriv ( ) const

§ 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 799 of file canonicalform.cc.

800 {
801  int what = is_imm( value );
802  if ( what ) {
803  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
804  if ( (what = is_imm( cf.value )) == FFMARK )
805  value = imm_div_p( value, cf.value );
806  else if ( what == GFMARK )
807  value = imm_div_gf( value, cf.value );
808  else if ( what )
809  value = imm_div( value, cf.value );
810  else {
811  InternalCF * dummy = cf.value->copyObject();
812  value = dummy->divcoeff( value, true );
813  }
814  }
815  else if ( is_imm( cf.value ) )
816  value = value->divcoeff( cf.value, false );
817  else if ( value->level() == cf.value->level() ) {
818  if ( value->levelcoeff() == cf.value->levelcoeff() )
819  value = value->divsame( cf.value );
820  else if ( value->levelcoeff() > cf.value->levelcoeff() )
821  value = value->divcoeff( cf.value, false );
822  else {
823  InternalCF * dummy = cf.value->copyObject();
824  dummy = dummy->divcoeff( value, true );
825  if ( value->deleteObject() ) delete value;
826  value = dummy;
827  }
828  }
829  else if ( level() > cf.level() )
830  value = value->divcoeff( cf.value, false );
831  else {
832  InternalCF * dummy = cf.value->copyObject();
833  dummy = dummy->divcoeff( value, true );
834  if ( value->deleteObject() ) delete value;
835  value = dummy;
836  }
837  return *this;
838 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:380
virtual InternalCF * divsame(InternalCF *) PVIRT_INTCF("divsame")
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:385
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
InternalCF * imm_div(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:352
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1824 of file canonicalform.cc.

1825 {
1826  int what = is_imm( value );
1827  if ( what == FFMARK )
1829  else if ( what == GFMARK )
1831  else if ( what )
1832  return CanonicalForm( CFFactory::basic( IntegerDomain, 1L ) );
1833  else
1834  return CanonicalForm( value->genOne() );
1835 }
const long GFMARK
Definition: imm.h:39
const long FFMARK
Definition: imm.h:38
#define IntegerDomain
Definition: cf_defs.h:25
virtual InternalCF * genOne() PVIRT_INTCF("genOne")
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define GaloisFieldDomain
Definition: cf_defs.h:22
#define FiniteFieldDomain
Definition: cf_defs.h:23

§ 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 1810 of file canonicalform.cc.

1811 {
1812  int what = is_imm( value );
1813  if ( what == FFMARK )
1815  else if ( what == GFMARK )
1817  else if ( what )
1818  return CanonicalForm( CFFactory::basic( IntegerDomain, 0L ) );
1819  else
1820  return CanonicalForm( value->genZero() );
1821 }
const long GFMARK
Definition: imm.h:39
const long FFMARK
Definition: imm.h:38
#define IntegerDomain
Definition: cf_defs.h:25
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define GaloisFieldDomain
Definition: cf_defs.h:22
virtual InternalCF * genZero() PVIRT_INTCF("genZero")
#define FiniteFieldDomain
Definition: cf_defs.h:23

§ genZero() [2/3]

CanonicalForm CanonicalForm::genZero ( ) const

§ genZero() [3/3]

CanonicalForm CanonicalForm::genZero ( ) const

§ getval() [1/3]

InternalCF * CanonicalForm::getval ( ) const

Definition at line 33 of file canonicalform.cc.

34 {
35  if ( is_imm( value ) )
36  return value;
37  else
38  return value->copyObject();
39 }
InternalCF * copyObject()
Definition: int_cf.h:58
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 1354 of file canonicalform.cc.

1355 {
1356  if ( is_imm( value ) )
1357  {
1358  ASSERT( is_imm( value ) == INTMARK, "ilog2() not implemented" );
1359  long a = imm2int( value );
1360  ASSERT( a > 0, "arg to ilog2() less or equal zero" );
1361  int n = -1;
1362  while ( a > 0 )
1363  {
1364  n++;
1365  a /=2;
1366  }
1367  return n;
1368  }
1369  else
1370  return value->ilog2();
1371 }
const poly a
Definition: syzextra.cc:212
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual int ilog2()
int InternalCF::ilog2 ()
Definition: int_cf.cc:110
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ ilog2() [2/3]

int CanonicalForm::ilog2 ( ) const

§ ilog2() [3/3]

int CanonicalForm::ilog2 ( ) const

§ inBaseDomain() [1/3]

bool CanonicalForm::inBaseDomain ( ) const

Definition at line 103 of file canonicalform.cc.

104 {
105  if ( is_imm( value ) )
106  return true;
107  else
108  return value->inBaseDomain();
109 }
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual bool inBaseDomain() const
Definition: int_cf.h:70

§ inBaseDomain() [2/3]

bool CanonicalForm::inBaseDomain ( ) const

§ inBaseDomain() [3/3]

bool CanonicalForm::inBaseDomain ( ) const

§ inCoeffDomain() [1/3]

bool CanonicalForm::inCoeffDomain ( ) const

Definition at line 121 of file canonicalform.cc.

122 {
123  if ( is_imm( value ) )
124  return true;
125  else
126  return value->inCoeffDomain();
127 }
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ inCoeffDomain() [2/3]

bool CanonicalForm::inCoeffDomain ( ) const

§ inCoeffDomain() [3/3]

bool CanonicalForm::inCoeffDomain ( ) const

§ inExtension() [1/3]

bool CanonicalForm::inExtension ( ) const

Definition at line 112 of file canonicalform.cc.

113 {
114  if ( is_imm( value ) )
115  return false;
116  else
117  return value->inExtension();
118 }
InternalCF * value
Definition: canonicalform.h:81
virtual bool inExtension() const
Definition: int_cf.h:71
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ inExtension() [2/3]

bool CanonicalForm::inExtension ( ) const

§ inExtension() [3/3]

bool CanonicalForm::inExtension ( ) const

§ inFF() [1/3]

bool CanonicalForm::inFF ( ) const

Definition at line 91 of file canonicalform.cc.

92 {
93  return is_imm( value ) == FFMARK;
94 }
const long FFMARK
Definition: imm.h:38
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ inFF() [2/3]

bool CanonicalForm::inFF ( ) const

§ inFF() [3/3]

bool CanonicalForm::inFF ( ) const

§ inGF() [1/3]

bool CanonicalForm::inGF ( ) const

Definition at line 97 of file canonicalform.cc.

98 {
99  return is_imm( value ) == GFMARK;
100 }
const long GFMARK
Definition: imm.h:39
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ inGF() [2/3]

bool CanonicalForm::inGF ( ) const

§ inGF() [3/3]

bool CanonicalForm::inGF ( ) const

§ inPolyDomain() [1/3]

bool CanonicalForm::inPolyDomain ( ) const

Definition at line 130 of file canonicalform.cc.

131 {
132  if ( is_imm( value ) )
133  return false;
134  else
135  return value->inPolyDomain();
136 }
InternalCF * value
Definition: canonicalform.h:81
virtual bool inPolyDomain() const
Definition: int_cf.h:73
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ inPolyDomain() [2/3]

bool CanonicalForm::inPolyDomain ( ) const

§ inPolyDomain() [3/3]

bool CanonicalForm::inPolyDomain ( ) const

§ inQ() [1/3]

bool CanonicalForm::inQ ( ) const

Definition at line 79 of file canonicalform.cc.

80 {
81  if ( is_imm( value ) == INTMARK )
82  return true;
83  else if ( is_imm( value ) )
84  return false;
85  else
86  return value->levelcoeff() == IntegerDomain ||
88 }
#define IntegerDomain
Definition: cf_defs.h:25
virtual int levelcoeff() const
Definition: int_cf.h:64
#define RationalDomain
Definition: cf_defs.h:24
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37

§ inQ() [2/3]

bool CanonicalForm::inQ ( ) const

§ inQ() [3/3]

bool CanonicalForm::inQ ( ) const

§ inQuotDomain() [1/3]

bool CanonicalForm::inQuotDomain ( ) const

Definition at line 139 of file canonicalform.cc.

140 {
141  if ( is_imm( value ) )
142  return false;
143  else
144  return value->inQuotDomain();
145 }
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual bool inQuotDomain() const
Definition: int_cf.h:74

§ 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 199 of file canonicalform.cc.

200 {
201  if ( is_imm( value ) )
202  return imm_intval( value );
203  else
204  return value->intval();
205 }
virtual long intval() const
Definition: int_cf.cc:165
long imm_intval(const InternalCF *const op)
Definition: imm.h:160
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 68 of file canonicalform.cc.

69 {
70  if ( is_imm( value ) == INTMARK )
71  return true;
72  else if ( is_imm( value ) )
73  return false;
74  else
75  return value->levelcoeff() == IntegerDomain;
76 }
#define IntegerDomain
Definition: cf_defs.h:25
virtual int levelcoeff() const
Definition: int_cf.h:64
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37

§ inZ() [2/3]

bool CanonicalForm::inZ ( ) const

§ inZ() [3/3]

bool CanonicalForm::inZ ( ) const

§ isFFinGF() [1/3]

bool CanonicalForm::isFFinGF ( ) const

Definition at line 148 of file canonicalform.cc.

149 {
150  return is_imm( value ) == GFMARK && gf_isff( imm2int( value ) );
151 }
const long GFMARK
Definition: imm.h:39
bool gf_isff(long a)
Definition: gfops.cc:270
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ isFFinGF() [2/3]

bool CanonicalForm::isFFinGF ( ) const

§ isFFinGF() [3/3]

bool CanonicalForm::isFFinGF ( ) const

§ isHomogeneous() [1/3]

bool CanonicalForm::isHomogeneous ( ) const

Definition at line 164 of file canonicalform.cc.

165 {
166  if (this->isZero()) return true;
167  else if (this->inCoeffDomain()) return true;
168  else
169  {
170 #if 0
171  CFIterator i;
172  int cdeg = -2, dummy;
173  for ( i = *this; i.hasTerms(); i++ )
174  {
175  if (!(i.coeff().isHomogeneous())) return false;
176  if ( (dummy = totaldegree( i.coeff() ) + i.exp()) != cdeg )
177  {
178  if (cdeg == -2) cdeg = dummy;
179  else return false;
180  }
181  }
182  return true;
183 #else
184  CFList termlist= get_Terms(*this);
186  int deg= totaldegree(termlist.getFirst());
187 
188  for ( i=termlist; i.hasItem(); i++ )
189  if ( totaldegree(i.getItem()) != deg ) return false;
190  return true;
191 #endif
192  }
193 }
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
T getFirst() const
Definition: ftmpl_list.cc:279
CFList get_Terms(const CanonicalForm &f)
Definition: cf_factor.cc:274
T & getItem() const
Definition: ftmpl_list.cc:431
int i
Definition: cfEzgcd.cc:123
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
bool isHomogeneous() const
int totaldegree(const CanonicalForm &f)
int totaldegree ( const CanonicalForm & f )
Definition: cf_ops.cc:523
CF_NO_INLINE int exp() const
get the current exponent
bool inCoeffDomain() const

§ 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 103 of file canonicalform.h.

103 { return is_imm( value ); };
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ isImm() [2/3]

bool CanonicalForm::isImm ( ) const
inline

Definition at line 247 of file factory.h.

247 { return is_imm( value ); };
int is_imm(const InternalCF *const ptr)
Definition: factory.h:204
InternalCF * value
Definition: canonicalform.h:81

§ isImm() [3/3]

bool CanonicalForm::isImm ( ) const
inline

Definition at line 247 of file factory.h.

247 { return is_imm( value ); };
int is_imm(const InternalCF *const ptr)
Definition: factory.h:204
InternalCF * value
Definition: canonicalform.h:81

§ 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 }
virtual bool isOne() const
bool InternalCF::isOne, isZero () const
Definition: int_cf.cc:18
const long FFMARK
Definition: imm.h:38
int imm_isone_p(const InternalCF *const ptr)
Definition: imm.h:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int imm_isone_gf(const InternalCF *const ptr)
Definition: imm.h:132
int imm_isone(const InternalCF *const ptr)
Definition: imm.h:120
const long INTMARK
Definition: imm.h:37

§ 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 154 of file canonicalform.cc.

155 {
156  if ( is_imm( value ) )
157  return false;
158  else
159  return value->isUnivariate();
160 }
virtual bool isUnivariate() const
Definition: int_cf.h:77
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 }
int imm_iszero_p(const InternalCF *const ptr)
Definition: imm.h:147
const long FFMARK
Definition: imm.h:38
virtual bool isZero() const
Definition: int_cf.cc:24
int imm_iszero_gf(const InternalCF *const ptr)
Definition: imm.h:153
int imm_iszero(const InternalCF *const ptr)
Definition: imm.h:141
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37

§ 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 306 of file canonicalform.cc.

307 {
308  if ( is_imm( value ) )
309  return *this;
310  else
311  return value->lc();
312 }
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual CanonicalForm lc()
CanonicalForm InternalCF::lc (), Lc (), LC ()
Definition: int_cf.cc:34

§ 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 321 of file canonicalform.cc.

322 {
323  if ( is_imm( value ) || value->inCoeffDomain() )
324  return *this;
325  else
326  return value->Lc();
327 }
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
virtual CanonicalForm Lc()
Definition: int_cf.cc:40
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 336 of file canonicalform.cc.

337 {
338  if ( is_imm( value ) )
339  return *this;
340  else
341  return value->LC();
342 }
virtual CanonicalForm LC()
Definition: int_cf.cc:46
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ LC() [2/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 351 of file canonicalform.cc.

352 {
353  if ( is_imm( value ) || value->inCoeffDomain() )
354  return *this;
355 
356  Variable x = value->variable();
357  if ( v > x )
358  return *this;
359  else if ( v == x )
360  return value->LC();
361  else {
362  CanonicalForm f = swapvar( *this, v, x );
363  if ( f.mvar() == x )
364  return swapvar( f.value->LC(), v, x );
365  else
366  // v did not occur in f
367  return *this;
368  }
369 }
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: factory.h:115
virtual CanonicalForm LC()
Definition: int_cf.cc:46
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
InternalCF * value
Definition: canonicalform.h:81
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
virtual Variable variable() const
Definition: int_cf.h:66

§ lc() [2/3]

CanonicalForm CanonicalForm::lc ( ) const

§ lc() [3/3]

CanonicalForm CanonicalForm::lc ( ) const

§ Lc() [2/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

§ 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 545 of file canonicalform.cc.

546 {
547  if ( is_imm( value ) )
548  return LEVELBASE;
549  else
550  return value->level();
551 }
#define LEVELBASE
Definition: cf_defs.h:16
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ level() [2/3]

int CanonicalForm::level ( ) const

§ level() [3/3]

int CanonicalForm::level ( ) const

§ mapinto() [1/3]

CanonicalForm CanonicalForm::mapinto ( ) const

Definition at line 208 of file canonicalform.cc.

209 {
210  //ASSERT( is_imm( value ) || ! value->inExtension(), "cannot map into different Extension" );
211  if ( is_imm( value ) )
212  if ( getCharacteristic() == 0 )
213  if ( is_imm( value ) == FFMARK )
214  return CanonicalForm( int2imm( ff_symmetric( imm2int( value ) ) ) );
215  else if ( is_imm( value ) == GFMARK )
216  return CanonicalForm( int2imm( ff_symmetric( gf_gf2ff( imm2int( value ) ) ) ) );
217  else
218  return *this;
219  else if ( getGFDegree() == 1 )
220  return CanonicalForm( int2imm_p( ff_norm( imm2int( value ) ) ) );
221  else
222  return CanonicalForm( int2imm_gf( gf_int2gf( imm2int( value ) ) ) );
223  else if ( value->inBaseDomain() )
224  if ( getCharacteristic() == 0 )
225  return *this;
226  else
227  {
228  int val;
229  if ( value->levelcoeff() == IntegerDomain )
230  val = value->intmod( ff_prime );
231  else if ( value->levelcoeff() == RationalDomain )
232  return num().mapinto() / den().mapinto();
233  else {
234  ASSERT( 0, "illegal domain" );
235  return 0;
236  }
237  if ( getGFDegree() > 1 )
238  return CanonicalForm( int2imm_gf( gf_int2gf( val ) ) );
239  else
240  return CanonicalForm( int2imm_p( val ) );
241  }
242  else
243  {
244  Variable x = value->variable();
246  for ( CFIterator i = *this; i.hasTerms(); i++ )
247  result += (power( x, i.exp() ) * i.coeff().mapinto());
248  return result;
249  }
250 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
const long GFMARK
Definition: imm.h:39
InternalCF * int2imm(long i)
Definition: imm.h:71
factory&#39;s class for variables
Definition: factory.h:115
long gf_gf2ff(long a)
Definition: gfops.cc:226
factory&#39;s main class
Definition: canonicalform.h:75
const long FFMARK
Definition: imm.h:38
InternalCF * int2imm_p(long i)
Definition: imm.h:97
int ff_norm(const int a)
Definition: ffops.h:35
int getCharacteristic()
Definition: cf_char.cc:51
#define IntegerDomain
Definition: cf_defs.h:25
virtual int levelcoeff() const
Definition: int_cf.h:64
CanonicalForm mapinto() const
CanonicalForm num() const
num() returns the numerator of CO if CO is a rational number, CO itself otherwise.
InternalCF * int2imm_gf(long i)
Definition: imm.h:102
int i
Definition: cfEzgcd.cc:123
#define RationalDomain
Definition: cf_defs.h:24
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual int intmod(int) const
Definition: int_cf.h:79
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
CanonicalForm den() const
den() returns the denominator of CO if CO is a rational number, 1 (from the current domain!) otherwis...
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int getGFDegree()
Definition: cf_char.cc:56
Variable x
Definition: cfModGcd.cc:4023
int gf_int2gf(int i)
Definition: gfops.h:65
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int ff_prime
Definition: ffops.cc:14
virtual bool inBaseDomain() const
Definition: int_cf.h:70
return result
Definition: facAbsBiFact.cc:76
virtual Variable variable() const
Definition: int_cf.h:66
int ff_symmetric(const int a)
Definition: ffops.h:59

§ 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 927 of file canonicalform.cc.

928 {
929  int what = is_imm( value );
930  if ( what ) {
931  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
932  if ( (what = is_imm( cf.value )) == FFMARK )
933  value = imm_mod_p( value, cf.value );
934  else if ( what == GFMARK )
935  value = imm_mod_gf( value, cf.value );
936  else if ( what )
937  value = imm_mod( value, cf.value );
938  else {
939  InternalCF * dummy = cf.value->copyObject();
940  value = dummy->modcoeff( value, true );
941  }
942  }
943  else if ( is_imm( cf.value ) )
944  value = value->modcoeff( cf.value, false );
945  else if ( value->level() == cf.value->level() ) {
946  if ( value->levelcoeff() == cf.value->levelcoeff() )
947  value = value->modsame( cf.value );
948  else if ( value->levelcoeff() > cf.value->levelcoeff() )
949  value = value->modcoeff( cf.value, false );
950  else {
951  InternalCF * dummy = cf.value->copyObject();
952  dummy = dummy->modcoeff( value, true );
953  if ( value->deleteObject() ) delete value;
954  value = dummy;
955  }
956  }
957  else if ( level() > cf.level() )
958  value = value->modcoeff( cf.value, false );
959  else {
960  InternalCF * dummy = cf.value->copyObject();
961  dummy = dummy->modcoeff( value, true );
962  if ( value->deleteObject() ) delete value;
963  value = dummy;
964  }
965  return *this;
966 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:390
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
Definition: imm.h:414
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * modsame(InternalCF *) PVIRT_INTCF("modsame")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual InternalCF * modcoeff(InternalCF *, bool) PVIRT_INTCF("modcoeff")
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
Definition: imm.h:419

§ 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 51 of file canonicalform.cc.

52 {
53  ASSERT (!is_imm (value) && value->levelcoeff() == IntegerDomain, "non-immediate integer expected");
54  getmpi (value, val);
55 }
#define IntegerDomain
Definition: cf_defs.h:25
virtual int levelcoeff() const
Definition: int_cf.h:64
void getmpi(InternalCF *value, mpz_t mpi)
Definition: cf_factory.cc:255
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 562 of file canonicalform.cc.

563 {
564  if ( is_imm( value ) )
565  return Variable();
566  else
567  return value->variable();
568 }
factory&#39;s class for variables
Definition: factory.h:115
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual Variable variable() const
Definition: int_cf.h:66

§ 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 580 of file canonicalform.cc.

581 {
582  if ( is_imm( value ) )
583  return *this;
584  else
585  return CanonicalForm( value->num() );
586 }
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * num()
InternalCF * InternalCF::num (), den ()
Definition: int_cf.cc:85
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 885 of file canonicalform.cc.

886 {
887  int what = is_imm( value );
888  if ( what ) {
889  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
890  if ( (what = is_imm( cf.value )) == FFMARK )
891  value = imm_mod_p( value, cf.value );
892  else if ( what == GFMARK )
893  value = imm_mod_gf( value, cf.value );
894  else if ( what )
895  value = imm_mod( value, cf.value );
896  else {
897  InternalCF * dummy = cf.value->copyObject();
898  value = dummy->modulocoeff( value, true );
899  }
900  }
901  else if ( is_imm( cf.value ) )
902  value = value->modulocoeff( cf.value, false );
903  else if ( value->level() == cf.value->level() ) {
904  if ( value->levelcoeff() == cf.value->levelcoeff() )
905  value = value->modulosame( cf.value );
906  else if ( value->levelcoeff() > cf.value->levelcoeff() )
907  value = value->modulocoeff( cf.value, false );
908  else {
909  InternalCF * dummy = cf.value->copyObject();
910  dummy = dummy->modulocoeff( value, true );
911  if ( value->deleteObject() ) delete value;
912  value = dummy;
913  }
914  }
915  else if ( level() > cf.level() )
916  value = value->modulocoeff( cf.value, false );
917  else {
918  InternalCF * dummy = cf.value->copyObject();
919  dummy = dummy->modulocoeff( value, true );
920  if ( value->deleteObject() ) delete value;
921  value = dummy;
922  }
923  return *this;
924 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * imm_mod(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:390
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual InternalCF * modulosame(InternalCF *) PVIRT_INTCF("modulosame")
virtual int level() const
Definition: int_cf.h:63
InternalCF * imm_mod_p(const InternalCF *const, const InternalCF *const)
Definition: imm.h:414
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual InternalCF * modulocoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99
InternalCF * imm_mod_gf(const InternalCF *const, const InternalCF *const)
Definition: imm.h:419

§ 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 1106 of file canonicalform.cc.

1107 {
1108  if ( is_imm( value ) || value->inBaseDomain() )
1109  return *this;
1110  else {
1111 #if 0
1112  CFIterator i = *this;
1113  int lastExp = i.exp();
1114  CanonicalForm result = i.coeff();
1115  i++;
1116  while ( i.hasTerms() ) {
1117  if ( (lastExp - i.exp()) == 1 )
1118  result *= f;
1119  else
1120  result *= power( f, lastExp - i.exp() );
1121  result += i.coeff();
1122  lastExp = i.exp();
1123  i++;
1124  }
1125  if ( lastExp != 0 )
1126  result *= power( f, lastExp );
1127 #else
1128  CFIterator i = *this;
1129  int lastExp = i.exp();
1130  CanonicalForm result = i.coeff();
1131  i++;
1132  while ( i.hasTerms() )
1133  {
1134  int i_exp=i.exp();
1135  if ( (lastExp - i_exp /* i.exp()*/) == 1 )
1136  result *= f;
1137  else
1138  result *= power( f, lastExp - i_exp /*i.exp()*/ );
1139  result += i.coeff();
1140  lastExp = i_exp /*i.exp()*/;
1141  i++;
1142  }
1143  if ( lastExp != 0 )
1144  result *= power( f, lastExp );
1145 #endif
1146  return result;
1147  }
1148 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
factory&#39;s main class
Definition: canonicalform.h:75
int i
Definition: cfEzgcd.cc:123
InternalCF * value
Definition: canonicalform.h:81
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
CF_NO_INLINE int hasTerms() const
check if iterator has reached < the end of CanonicalForm
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
CF_NO_INLINE int exp() const
get the current exponent
virtual bool inBaseDomain() const
Definition: int_cf.h:70
return result
Definition: facAbsBiFact.cc:76

§ operator()() [2/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 1158 of file canonicalform.cc.

1159 {
1160  if ( is_imm( value ) || value->inBaseDomain() )
1161  return *this;
1162 
1163  Variable x = value->variable();
1164  if ( v > x )
1165  return *this;
1166  else if ( v == x )
1167  return (*this)( f );
1168  else {
1169  // v is less than main variable of f
1170  CanonicalForm result = 0;
1171  for ( CFIterator i = *this; i.hasTerms(); i++ )
1172  result += i.coeff()( f, v ) * power( x, i.exp() );
1173  return result;
1174  }
1175 }
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: factory.h:115
factory&#39;s main class
Definition: canonicalform.h:75
int i
Definition: cfEzgcd.cc:123
InternalCF * value
Definition: canonicalform.h:81
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
virtual bool inBaseDomain() const
Definition: int_cf.h:70
return result
Definition: facAbsBiFact.cc:76
virtual Variable variable() const
Definition: int_cf.h:66

§ operator()() [3/6]

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

§ operator()() [4/6]

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

§ 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 691 of file canonicalform.cc.

692 {
693  int what = is_imm( value );
694  if ( what ) {
695  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
696  if ( (what = is_imm( cf.value )) == FFMARK )
697  value = imm_mul_p( value, cf.value );
698  else if ( what == GFMARK )
699  value = imm_mul_gf( value, cf.value );
700  else if ( what )
701  value = imm_mul( value, cf.value );
702  else {
703  InternalCF * dummy = cf.value->copyObject();
704  value = dummy->mulcoeff( value );
705  }
706  }
707  else if ( is_imm( cf.value ) )
708  value = value->mulcoeff( cf.value );
709  else if ( value->level() == cf.value->level() ) {
710 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
711  if (value->levelcoeff() == cf.value->levelcoeff() && cf.isUnivariate() && (*this).isUnivariate())
712  {
713  if (value->level() < 0 || CFFactory::gettype() == GaloisFieldDomain || (size (cf) <= 10 || size (*this) <= 10) )
714  value = value->mulsame( cf.value );
715  else
716  *this= mulNTL (*this, cf);
717  }
718  else if (value->levelcoeff() == cf.value->levelcoeff() && (!cf.isUnivariate() || !(*this).isUnivariate()))
719  value = value->mulsame( cf.value );
720 #else
721  if ( value->levelcoeff() == cf.value->levelcoeff() )
722  value = value->mulsame( cf.value );
723 #endif
724  else if ( value->levelcoeff() > cf.value->levelcoeff() )
725  value = value->mulcoeff( cf.value );
726  else {
727  InternalCF * dummy = cf.value->copyObject();
728  dummy = dummy->mulcoeff( value );
729  if ( value->deleteObject() ) delete value;
730  value = dummy;
731  }
732  }
733  else if ( level() > cf.level() )
734  value = value->mulcoeff( cf.value );
735  else {
736  InternalCF * dummy = cf.value->copyObject();
737  dummy = dummy->mulcoeff( value );
738  if ( value->deleteObject() ) delete value;
739  value = dummy;
740  }
741  return *this;
742 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * imm_mul_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:347
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
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), Z, Q, Q(a), if we are in GF factory&#39;s default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f).
Definition: facMul.cc:407
bool isUnivariate() const
InternalCF * value
Definition: canonicalform.h:81
InternalCF * imm_mul(InternalCF *lhs, InternalCF *rhs)
Definition: imm.h:304
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
InternalCF * imm_mul_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:342
static int gettype()
Definition: cf_factory.h:27
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define GaloisFieldDomain
Definition: cf_defs.h:22
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")

§ 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 607 of file canonicalform.cc.

608 {
609  int what = is_imm( value );
610  if ( what ) {
611  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
612  if ( (what = is_imm( cf.value )) == FFMARK )
613  value = imm_add_p( value, cf.value );
614  else if ( what == GFMARK )
615  value = imm_add_gf( value, cf.value );
616  else if ( what )
617  value = imm_add( value, cf.value );
618  else {
619  InternalCF * dummy = cf.value->copyObject();
620  value = dummy->addcoeff( value );
621  }
622  }
623  else if ( is_imm( cf.value ) )
624  value = value->addcoeff( cf.value );
625  else if ( value->level() == cf.value->level() ) {
626  if ( value->levelcoeff() == cf.value->levelcoeff() )
627  value = value->addsame( cf.value );
628  else if ( value->levelcoeff() > cf.value->levelcoeff() )
629  value = value->addcoeff( cf.value );
630  else {
631  InternalCF * dummy = cf.value->copyObject();
632  dummy = dummy->addcoeff( value );
633  if ( value->deleteObject() ) delete value;
634  value = dummy;
635  }
636  }
637  else if ( level() > cf.level() )
638  value = value->addcoeff( cf.value );
639  else {
640  InternalCF * dummy = cf.value->copyObject();
641  dummy = dummy->addcoeff( value );
642  if ( value->deleteObject() ) delete value;
643  value = dummy;
644  }
645  return *this;
646 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * imm_add_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:279
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
virtual InternalCF * addsame(InternalCF *) PVIRT_INTCF("addsame")
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * addcoeff(InternalCF *) PVIRT_INTCF("addcoeff")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
InternalCF * imm_add(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:265
InternalCF * imm_add_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:274
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 649 of file canonicalform.cc.

650 {
651  int what = is_imm( value );
652  if ( what ) {
653  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
654  if ( (what = is_imm( cf.value )) == FFMARK )
655  value = imm_sub_p( value, cf.value );
656  else if ( what == GFMARK )
657  value = imm_sub_gf( value, cf.value );
658  else if ( what )
659  value = imm_sub( value, cf.value );
660  else {
661  InternalCF * dummy = cf.value->copyObject();
662  value = dummy->subcoeff( value, true );
663  }
664  }
665  else if ( is_imm( cf.value ) )
666  value = value->subcoeff( cf.value, false );
667  else if ( value->level() == cf.value->level() ) {
668  if ( value->levelcoeff() == cf.value->levelcoeff() )
669  value = value->subsame( cf.value );
670  else if ( value->levelcoeff() > cf.value->levelcoeff() )
671  value = value->subcoeff( cf.value, false );
672  else {
673  InternalCF * dummy = cf.value->copyObject();
674  dummy = dummy->subcoeff( value, true );
675  if ( value->deleteObject() ) delete value;
676  value = dummy;
677  }
678  }
679  else if ( level() > cf.level() )
680  value = value->subcoeff( cf.value, false );
681  else {
682  InternalCF * dummy = cf.value->copyObject();
683  dummy = dummy->subcoeff( value, true );
684  if ( value->deleteObject() ) delete value;
685  value = dummy;
686  }
687  return *this;
688 }
int deleteObject()
Definition: int_cf.h:57
InternalCF * imm_sub(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:284
const long GFMARK
Definition: imm.h:39
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual InternalCF * subsame(InternalCF *) PVIRT_INTCF("subsame")
virtual int level() const
Definition: int_cf.h:63
virtual InternalCF * subcoeff(InternalCF *, bool) PVIRT_INTCF("subcoeff")
InternalCF * imm_sub_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:298
InternalCF * value
Definition: canonicalform.h:81
InternalCF * imm_sub_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:293
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 745 of file canonicalform.cc.

746 {
747  int what = is_imm( value );
748  if ( what ) {
749  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
750  if ( (what = is_imm( cf.value )) == FFMARK )
751  value = imm_div_p( value, cf.value );
752  else if ( what == GFMARK )
753  value = imm_div_gf( value, cf.value );
754  else if ( what )
755  value = imm_divrat( value, cf.value );
756  else {
757  InternalCF * dummy = cf.value->copyObject();
758  value = dummy->dividecoeff( value, true );
759  }
760  }
761  else if ( is_imm( cf.value ) )
762  value = value->dividecoeff( cf.value, false );
763  else if ( value->level() == cf.value->level() ) {
764 #if (HAVE_NTL && HAVE_FLINT && __FLINT_RELEASE >= 20400)
765  if ( value->levelcoeff() == cf.value->levelcoeff() && (*this).isUnivariate() && cf.isUnivariate())
766  {
767  if (value->level() < 0 || CFFactory::gettype() == GaloisFieldDomain)
768  value = value->dividesame( cf.value );
769  else
770  *this= divNTL (*this, cf);
771  }
772  else if (value->levelcoeff() == cf.value->levelcoeff() && (!cf.isUnivariate() || !(*this).isUnivariate()))
773  value = value->dividesame( cf.value );
774 #else
775  if (value->levelcoeff() == cf.value->levelcoeff() )
776  value = value->dividesame( cf.value );
777 #endif
778  else if ( value->levelcoeff() > cf.value->levelcoeff() )
779  value = value->dividecoeff( cf.value, false );
780  else {
781  InternalCF * dummy = cf.value->copyObject();
782  dummy = dummy->dividecoeff( value, true );
783  if ( value->deleteObject() ) delete value;
784  value = dummy;
785  }
786  }
787  else if ( level() > cf.level() )
788  value = value->dividecoeff( cf.value, false );
789  else {
790  InternalCF * dummy = cf.value->copyObject();
791  dummy = dummy->dividecoeff( value, true );
792  if ( value->deleteObject() ) delete value;
793  value = dummy;
794  }
795  return *this;
796 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:380
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:385
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
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, Q, Q(a), if we are in GF factory&#39;s default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked
Definition: facMul.cc:850
bool isUnivariate() const
virtual InternalCF * dividesame(InternalCF *) PVIRT_INTCF("dividesame")
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
InternalCF * value
Definition: canonicalform.h:81
static int gettype()
Definition: cf_factory.h:27
InternalCF * imm_divrat(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:364
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define GaloisFieldDomain
Definition: cf_defs.h:22
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 }
int deleteObject()
Definition: int_cf.h:57
InternalCF * copyObject()
Definition: int_cf.h:58
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ operator=() [2/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 }
int deleteObject()
Definition: int_cf.h:57
static InternalCF * basic(long value)
Definition: cf_factory.cc:28
InternalCF * value
Definition: canonicalform.h:81
CanonicalForm cf
Definition: cfModGcd.cc:4024
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ operator=() [3/6]

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

§ operator=() [4/6]

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

§ 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 1214 of file canonicalform.cc.

1215 {
1216  ASSERT( i >= 0, "index to operator [] less than zero" );
1217  if ( is_imm( value ) )
1218  if ( i == 0 )
1219  return *this;
1220  else
1221  return CanonicalForm( 0 );
1222  else
1223  return value->coeff( i );
1224 }
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
Definition: int_cf.cc:120
int i
Definition: cfEzgcd.cc:123
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ operator[]() [2/3]

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

§ operator[]() [3/3]

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

§ print() [1/2]

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

input/output

Definition at line 1776 of file canonicalform.cc.

1777 {
1778  if ( is_imm( value ) )
1779  imm_print( os, value, str );
1780  else
1781  value->print( os, str );
1782 }
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
InternalCF * value
Definition: canonicalform.h:81
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
Definition: imm.h:472
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ print() [2/2]

void CanonicalForm::print ( OSTREAM os) const

Definition at line 1785 of file canonicalform.cc.

1786 {
1787  if ( is_imm( value ) )
1788  imm_print( os, value, "" );
1789  else
1790  value->print( os, "" );
1791 }
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
InternalCF * value
Definition: canonicalform.h:81
void imm_print(OSTREAM &os, const InternalCF *const op, const char *const str)
Definition: imm.h:472
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 1297 of file canonicalform.cc.

1298 {
1299  if ( is_imm( value ) )
1300  return imm_sign( value );
1301  else
1302  return value->sign();
1303 }
virtual int sign() const PVIRT_INT("sign")
InternalCF * value
Definition: canonicalform.h:81
int imm_sign(const InternalCF *const op)
imm_sign() - return sign of immediate object.
Definition: imm.h:193
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ 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 1320 of file canonicalform.cc.

1321 {
1322  if ( is_imm( value ) ) {
1323  ASSERT( is_imm( value ) == INTMARK, "sqrt() not implemented" );
1324  long n = imm2int( value );
1325  ASSERT( n >= 0, "arg to sqrt() less than zero" );
1326  if ( n == 0 || n == 1 )
1327  return CanonicalForm( n );
1328  else {
1329  long x, y = n;
1330  do {
1331  x = y;
1332  // the intermediate result may not fit into an
1333  // integer, but the result does
1334  y = (unsigned long)(x + n/x)/2;
1335  } while ( y < x );
1336  return CanonicalForm( x );
1337  }
1338  }
1339  else
1340  return CanonicalForm( value->sqrt() );
1341 }
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
virtual InternalCF * sqrt()
InternalCF * InternalCF::sqrt ()
Definition: int_cf.cc:100
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 467 of file canonicalform.cc.

468 {
469  if ( is_imm( value ) || value->inCoeffDomain() )
470  return *this;
471  else
472  return value->tailcoeff();
473 }
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
Definition: int_cf.cc:67
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60

§ tailcoeff() [2/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 487 of file canonicalform.cc.

488 {
489  if ( is_imm( value ) || value->inCoeffDomain() )
490  return *this;
491 
492  Variable x = value->variable();
493  if ( v > x )
494  return *this;
495  else if ( v == x )
496  return value->tailcoeff();
497  else {
498  CanonicalForm f = swapvar( *this, v, x );
499  if ( f.mvar() == x )
500  return swapvar( f.value->tailcoeff(), v, x );
501  else
502  // v did not occur in f
503  return *this;
504  }
505 }
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: factory.h:115
virtual bool inCoeffDomain() const
Definition: int_cf.h:72
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
virtual CanonicalForm tailcoeff()
CanonicalForm InternalCF::tailcoeff (), int InternalCF::taildegree ()
Definition: int_cf.cc:67
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
InternalCF * value
Definition: canonicalform.h:81
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
Variable x
Definition: cfModGcd.cc:4023
virtual Variable variable() const
Definition: int_cf.h:66

§ tailcoeff() [3/6]

CanonicalForm CanonicalForm::tailcoeff ( ) const

§ tailcoeff() [4/6]

CanonicalForm CanonicalForm::tailcoeff ( ) const

§ 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 521 of file canonicalform.cc.

522 {
523  int what = is_imm( value );
524  if ( what )
525  if ( what == FFMARK )
526  return imm_iszero_p( value ) ? -1 : 0;
527  else if ( what == INTMARK )
528  return imm_iszero( value ) ? -1 : 0;
529  else
530  return imm_iszero_gf( value ) ? -1 : 0;
531  else
532  return value->taildegree();
533 }
int imm_iszero_p(const InternalCF *const ptr)
Definition: imm.h:147
const long FFMARK
Definition: imm.h:38
virtual int taildegree()
Definition: int_cf.cc:73
int imm_iszero_gf(const InternalCF *const ptr)
Definition: imm.h:153
int imm_iszero(const InternalCF *const ptr)
Definition: imm.h:141
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37

§ 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 842 of file canonicalform.cc.

843 {
844  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
845  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
846  fail= false;
847  int what = is_imm( value );
848  if ( what ) {
849  ASSERT ( ! is_imm( cf.value ) || (what==is_imm( cf.value )), "illegal base coefficients" );
850  if ( (what = is_imm( cf.value )) == FFMARK )
851  value = imm_div_p( value, cf.value );
852  else if ( what == GFMARK )
853  value = imm_div_gf( value, cf.value );
854  else {
855  InternalCF * dummy = cf.value->copyObject();
856  value = dummy->divcoeff( value, true );
857  }
858  }
859  else if ( is_imm( cf.value ) )
860  value = value->tryDivcoeff (cf.value, false, M, fail);
861  else if ( value->level() == cf.value->level() ) {
862  if ( value->levelcoeff() == cf.value->levelcoeff() )
863  value = value->tryDivsame( cf.value, M, fail );
864  else if ( value->levelcoeff() > cf.value->levelcoeff() )
865  value = value->tryDivcoeff( cf.value, false, M, fail );
866  else {
867  InternalCF * dummy = cf.value->copyObject();
868  dummy = dummy->tryDivcoeff( value, true, M, fail );
869  if ( value->deleteObject() ) delete value;
870  value = dummy;
871  }
872  }
873  else if ( level() > cf.level() )
874  value = value->tryDivcoeff( cf.value, false, M, fail );
875  else {
876  InternalCF * dummy = cf.value->copyObject();
877  dummy = dummy->tryDivcoeff( value, true, M, fail );
878  if ( value->deleteObject() ) delete value;
879  value = dummy;
880  }
881  return *this;
882 }
int deleteObject()
Definition: int_cf.h:57
const long GFMARK
Definition: imm.h:39
InternalCF * copyObject()
Definition: int_cf.h:58
const long FFMARK
Definition: imm.h:38
InternalCF * imm_div_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:380
InternalCF * imm_div_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:385
virtual InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_cf.cc:207
int getCharacteristic()
Definition: cf_char.cc:51
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
virtual InternalCF * divcoeff(InternalCF *, bool) PVIRT_INTCF("divcoeff")
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
virtual InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_cf.cc:214
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
int level() const
level() returns the level of CO.
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1665 of file canonicalform.cc.

1666 {
1667  // check immediate cases
1668  int what = is_imm( g.value );
1669  if ( is_imm( f.value ) ) {
1670  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1671  if ( what == 0 )
1672  return g.value->bextgcdcoeff( f.value, b, a );
1673  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1674  // calculate extended gcd using standard integer
1675  // arithmetic
1676  long fInt = imm2int( f.value );
1677  long gInt = imm2int( g.value );
1678 
1679  // to avoid any system dpendencies with `%', we work
1680  // with positive numbers only. To a pity, we have to
1681  // redo all the checks when assigning to a and b.
1682  if ( fInt < 0 ) fInt = -fInt;
1683  if ( gInt < 0 ) gInt = -gInt;
1684  // swap fInt and gInt
1685  if ( gInt > fInt ) {
1686  long swap = gInt;
1687  gInt = fInt;
1688  fInt = swap;
1689  }
1690 
1691  long u = 1; long v = 0;
1692  long uNext = 0; long vNext = 1;
1693 
1694  // at any step, we have:
1695  // fInt_0 * u + gInt_0 * v = fInt
1696  // fInt_0 * uNext + gInt_0 * vNext = gInt
1697  // where fInt_0 and gInt_0 denote the values of fint
1698  // and gInt, resp., at the beginning
1699  while ( gInt ) {
1700  long r = fInt % gInt;
1701  long q = fInt / gInt;
1702  long uSwap = u - q * uNext;
1703  long vSwap = v - q * vNext;
1704 
1705  // update variables
1706  fInt = gInt;
1707  gInt = r;
1708  u = uNext; v = vNext;
1709  uNext = uSwap; vNext = vSwap;
1710  }
1711 
1712  // now, assign to a and b
1713  long fTest = imm2int( f.value );
1714  long gTest = imm2int( g.value );
1715  if ( gTest > fTest ) {
1716  a = v; b = u;
1717  } else {
1718  a = u; b = v;
1719  }
1720  if ( fTest < 0 ) a = -a;
1721  if ( gTest < 0 ) b = -b;
1722  return CanonicalForm( fInt );
1723  } else
1724  // stupid special cases
1725  if ( ! f.isZero() ) {
1726  a = 1/f; b = 0; return CanonicalForm( 1 );
1727  } else if ( ! g.isZero() ) {
1728  a = 0; b = 1/g; return CanonicalForm( 1 );
1729  } else {
1730  a = 0; b = 0; return CanonicalForm( 0 );
1731  }
1732  }
1733  else if ( what )
1734  return f.value->bextgcdcoeff( g.value, a, b );
1735 
1736  int fLevel = f.value->level();
1737  int gLevel = g.value->level();
1738 
1739  // check levels
1740  if ( fLevel == gLevel ) {
1741  fLevel = f.value->levelcoeff();
1742  gLevel = g.value->levelcoeff();
1743 
1744  // check levelcoeffs
1745  if ( fLevel == gLevel )
1746  return f.value->bextgcdsame( g.value, a, b );
1747  else if ( fLevel < gLevel )
1748  return g.value->bextgcdcoeff( f.value, b, a );
1749  else
1750  return f.value->bextgcdcoeff( g.value, a, b );
1751  }
1752  else if ( fLevel < gLevel )
1753  return g.value->bextgcdcoeff( f.value, b, a );
1754  else
1755  return f.value->bextgcdcoeff( g.value, a, b );
1756 }
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
InternalCF * InternalCF::bextgcdsame ( InternalCF *, CanonicalForm & a, CanonicalForm & b ) ...
Definition: int_cf.cc:149
g
Definition: cfModGcd.cc:4031
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_cf.cc:157
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99
const poly b
Definition: syzextra.cc:213

§ 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 1665 of file canonicalform.cc.

1666 {
1667  // check immediate cases
1668  int what = is_imm( g.value );
1669  if ( is_imm( f.value ) ) {
1670  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1671  if ( what == 0 )
1672  return g.value->bextgcdcoeff( f.value, b, a );
1673  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1674  // calculate extended gcd using standard integer
1675  // arithmetic
1676  long fInt = imm2int( f.value );
1677  long gInt = imm2int( g.value );
1678 
1679  // to avoid any system dpendencies with `%', we work
1680  // with positive numbers only. To a pity, we have to
1681  // redo all the checks when assigning to a and b.
1682  if ( fInt < 0 ) fInt = -fInt;
1683  if ( gInt < 0 ) gInt = -gInt;
1684  // swap fInt and gInt
1685  if ( gInt > fInt ) {
1686  long swap = gInt;
1687  gInt = fInt;
1688  fInt = swap;
1689  }
1690 
1691  long u = 1; long v = 0;
1692  long uNext = 0; long vNext = 1;
1693 
1694  // at any step, we have:
1695  // fInt_0 * u + gInt_0 * v = fInt
1696  // fInt_0 * uNext + gInt_0 * vNext = gInt
1697  // where fInt_0 and gInt_0 denote the values of fint
1698  // and gInt, resp., at the beginning
1699  while ( gInt ) {
1700  long r = fInt % gInt;
1701  long q = fInt / gInt;
1702  long uSwap = u - q * uNext;
1703  long vSwap = v - q * vNext;
1704 
1705  // update variables
1706  fInt = gInt;
1707  gInt = r;
1708  u = uNext; v = vNext;
1709  uNext = uSwap; vNext = vSwap;
1710  }
1711 
1712  // now, assign to a and b
1713  long fTest = imm2int( f.value );
1714  long gTest = imm2int( g.value );
1715  if ( gTest > fTest ) {
1716  a = v; b = u;
1717  } else {
1718  a = u; b = v;
1719  }
1720  if ( fTest < 0 ) a = -a;
1721  if ( gTest < 0 ) b = -b;
1722  return CanonicalForm( fInt );
1723  } else
1724  // stupid special cases
1725  if ( ! f.isZero() ) {
1726  a = 1/f; b = 0; return CanonicalForm( 1 );
1727  } else if ( ! g.isZero() ) {
1728  a = 0; b = 1/g; return CanonicalForm( 1 );
1729  } else {
1730  a = 0; b = 0; return CanonicalForm( 0 );
1731  }
1732  }
1733  else if ( what )
1734  return f.value->bextgcdcoeff( g.value, a, b );
1735 
1736  int fLevel = f.value->level();
1737  int gLevel = g.value->level();
1738 
1739  // check levels
1740  if ( fLevel == gLevel ) {
1741  fLevel = f.value->levelcoeff();
1742  gLevel = g.value->levelcoeff();
1743 
1744  // check levelcoeffs
1745  if ( fLevel == gLevel )
1746  return f.value->bextgcdsame( g.value, a, b );
1747  else if ( fLevel < gLevel )
1748  return g.value->bextgcdcoeff( f.value, b, a );
1749  else
1750  return f.value->bextgcdcoeff( g.value, a, b );
1751  }
1752  else if ( fLevel < gLevel )
1753  return g.value->bextgcdcoeff( f.value, b, a );
1754  else
1755  return f.value->bextgcdcoeff( g.value, a, b );
1756 }
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
InternalCF * InternalCF::bextgcdsame ( InternalCF *, CanonicalForm & a, CanonicalForm & b ) ...
Definition: int_cf.cc:149
g
Definition: cfModGcd.cc:4031
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_cf.cc:157
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99
const poly b
Definition: syzextra.cc:213

§ 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 1665 of file canonicalform.cc.

1666 {
1667  // check immediate cases
1668  int what = is_imm( g.value );
1669  if ( is_imm( f.value ) ) {
1670  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1671  if ( what == 0 )
1672  return g.value->bextgcdcoeff( f.value, b, a );
1673  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) ) {
1674  // calculate extended gcd using standard integer
1675  // arithmetic
1676  long fInt = imm2int( f.value );
1677  long gInt = imm2int( g.value );
1678 
1679  // to avoid any system dpendencies with `%', we work
1680  // with positive numbers only. To a pity, we have to
1681  // redo all the checks when assigning to a and b.
1682  if ( fInt < 0 ) fInt = -fInt;
1683  if ( gInt < 0 ) gInt = -gInt;
1684  // swap fInt and gInt
1685  if ( gInt > fInt ) {
1686  long swap = gInt;
1687  gInt = fInt;
1688  fInt = swap;
1689  }
1690 
1691  long u = 1; long v = 0;
1692  long uNext = 0; long vNext = 1;
1693 
1694  // at any step, we have:
1695  // fInt_0 * u + gInt_0 * v = fInt
1696  // fInt_0 * uNext + gInt_0 * vNext = gInt
1697  // where fInt_0 and gInt_0 denote the values of fint
1698  // and gInt, resp., at the beginning
1699  while ( gInt ) {
1700  long r = fInt % gInt;
1701  long q = fInt / gInt;
1702  long uSwap = u - q * uNext;
1703  long vSwap = v - q * vNext;
1704 
1705  // update variables
1706  fInt = gInt;
1707  gInt = r;
1708  u = uNext; v = vNext;
1709  uNext = uSwap; vNext = vSwap;
1710  }
1711 
1712  // now, assign to a and b
1713  long fTest = imm2int( f.value );
1714  long gTest = imm2int( g.value );
1715  if ( gTest > fTest ) {
1716  a = v; b = u;
1717  } else {
1718  a = u; b = v;
1719  }
1720  if ( fTest < 0 ) a = -a;
1721  if ( gTest < 0 ) b = -b;
1722  return CanonicalForm( fInt );
1723  } else
1724  // stupid special cases
1725  if ( ! f.isZero() ) {
1726  a = 1/f; b = 0; return CanonicalForm( 1 );
1727  } else if ( ! g.isZero() ) {
1728  a = 0; b = 1/g; return CanonicalForm( 1 );
1729  } else {
1730  a = 0; b = 0; return CanonicalForm( 0 );
1731  }
1732  }
1733  else if ( what )
1734  return f.value->bextgcdcoeff( g.value, a, b );
1735 
1736  int fLevel = f.value->level();
1737  int gLevel = g.value->level();
1738 
1739  // check levels
1740  if ( fLevel == gLevel ) {
1741  fLevel = f.value->levelcoeff();
1742  gLevel = g.value->levelcoeff();
1743 
1744  // check levelcoeffs
1745  if ( fLevel == gLevel )
1746  return f.value->bextgcdsame( g.value, a, b );
1747  else if ( fLevel < gLevel )
1748  return g.value->bextgcdcoeff( f.value, b, a );
1749  else
1750  return f.value->bextgcdcoeff( g.value, a, b );
1751  }
1752  else if ( fLevel < gLevel )
1753  return g.value->bextgcdcoeff( f.value, b, a );
1754  else
1755  return f.value->bextgcdcoeff( g.value, a, b );
1756 }
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
InternalCF * InternalCF::bextgcdsame ( InternalCF *, CanonicalForm & a, CanonicalForm & b ) ...
Definition: int_cf.cc:149
g
Definition: cfModGcd.cc:4031
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_cf.cc:157
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99
const poly b
Definition: syzextra.cc:213

§ 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 1591 of file canonicalform.cc.

1592 {
1593  // check immediate cases
1594  int what = is_imm( g.value );
1595  if ( is_imm( f.value ) )
1596  {
1597  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1598  if ( what == 0 )
1599  return g.value->bgcdcoeff( f.value );
1600  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1601  {
1602  // calculate gcd using standard integer
1603  // arithmetic
1604  long fInt = imm2int( f.value );
1605  long gInt = imm2int( g.value );
1606 
1607  if ( fInt < 0 ) fInt = -fInt;
1608  if ( gInt < 0 ) gInt = -gInt;
1609  // swap fInt and gInt
1610  if ( gInt > fInt )
1611  {
1612  long swap = gInt;
1613  gInt = fInt;
1614  fInt = swap;
1615  }
1616 
1617  // now, 0 <= gInt <= fInt. Start the loop.
1618  while ( gInt )
1619  {
1620  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1621  long r = fInt % gInt;
1622  fInt = gInt;
1623  gInt = r;
1624  }
1625 
1626  return CanonicalForm( fInt );
1627  }
1628  else
1629  // we do not go for maximal speed for these stupid
1630  // special cases
1631  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1632  }
1633  else if ( what )
1634  return f.value->bgcdcoeff( g.value );
1635 
1636  int fLevel = f.value->level();
1637  int gLevel = g.value->level();
1638 
1639  // check levels
1640  if ( fLevel == gLevel )
1641  {
1642  fLevel = f.value->levelcoeff();
1643  gLevel = g.value->levelcoeff();
1644 
1645  // check levelcoeffs
1646  if ( fLevel == gLevel )
1647  return f.value->bgcdsame( g.value );
1648  else if ( fLevel < gLevel )
1649  return g.value->bgcdcoeff( f.value );
1650  else
1651  return f.value->bgcdcoeff( g.value );
1652  }
1653  else if ( fLevel < gLevel )
1654  return g.value->bgcdcoeff( f.value );
1655  else
1656  return f.value->bgcdcoeff( g.value );
1657 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bgcdcoeff(const InternalCF *const)
Definition: int_cf.cc:139
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual InternalCF * bgcdsame(const InternalCF *const) const
InternalCF * InternalCF::bgcdsame, bgcdcoeff ( const InternalCF * const )
Definition: int_cf.cc:132
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1591 of file canonicalform.cc.

1592 {
1593  // check immediate cases
1594  int what = is_imm( g.value );
1595  if ( is_imm( f.value ) )
1596  {
1597  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1598  if ( what == 0 )
1599  return g.value->bgcdcoeff( f.value );
1600  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1601  {
1602  // calculate gcd using standard integer
1603  // arithmetic
1604  long fInt = imm2int( f.value );
1605  long gInt = imm2int( g.value );
1606 
1607  if ( fInt < 0 ) fInt = -fInt;
1608  if ( gInt < 0 ) gInt = -gInt;
1609  // swap fInt and gInt
1610  if ( gInt > fInt )
1611  {
1612  long swap = gInt;
1613  gInt = fInt;
1614  fInt = swap;
1615  }
1616 
1617  // now, 0 <= gInt <= fInt. Start the loop.
1618  while ( gInt )
1619  {
1620  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1621  long r = fInt % gInt;
1622  fInt = gInt;
1623  gInt = r;
1624  }
1625 
1626  return CanonicalForm( fInt );
1627  }
1628  else
1629  // we do not go for maximal speed for these stupid
1630  // special cases
1631  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1632  }
1633  else if ( what )
1634  return f.value->bgcdcoeff( g.value );
1635 
1636  int fLevel = f.value->level();
1637  int gLevel = g.value->level();
1638 
1639  // check levels
1640  if ( fLevel == gLevel )
1641  {
1642  fLevel = f.value->levelcoeff();
1643  gLevel = g.value->levelcoeff();
1644 
1645  // check levelcoeffs
1646  if ( fLevel == gLevel )
1647  return f.value->bgcdsame( g.value );
1648  else if ( fLevel < gLevel )
1649  return g.value->bgcdcoeff( f.value );
1650  else
1651  return f.value->bgcdcoeff( g.value );
1652  }
1653  else if ( fLevel < gLevel )
1654  return g.value->bgcdcoeff( f.value );
1655  else
1656  return f.value->bgcdcoeff( g.value );
1657 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bgcdcoeff(const InternalCF *const)
Definition: int_cf.cc:139
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual InternalCF * bgcdsame(const InternalCF *const) const
InternalCF * InternalCF::bgcdsame, bgcdcoeff ( const InternalCF * const )
Definition: int_cf.cc:132
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1591 of file canonicalform.cc.

1592 {
1593  // check immediate cases
1594  int what = is_imm( g.value );
1595  if ( is_imm( f.value ) )
1596  {
1597  ASSERT( ! what || (what == is_imm( f.value )), "incompatible operands" );
1598  if ( what == 0 )
1599  return g.value->bgcdcoeff( f.value );
1600  else if ( what == INTMARK && ! cf_glob_switches.isOn( SW_RATIONAL ) )
1601  {
1602  // calculate gcd using standard integer
1603  // arithmetic
1604  long fInt = imm2int( f.value );
1605  long gInt = imm2int( g.value );
1606 
1607  if ( fInt < 0 ) fInt = -fInt;
1608  if ( gInt < 0 ) gInt = -gInt;
1609  // swap fInt and gInt
1610  if ( gInt > fInt )
1611  {
1612  long swap = gInt;
1613  gInt = fInt;
1614  fInt = swap;
1615  }
1616 
1617  // now, 0 <= gInt <= fInt. Start the loop.
1618  while ( gInt )
1619  {
1620  // calculate (fInt, gInt) = (gInt, fInt%gInt)
1621  long r = fInt % gInt;
1622  fInt = gInt;
1623  gInt = r;
1624  }
1625 
1626  return CanonicalForm( fInt );
1627  }
1628  else
1629  // we do not go for maximal speed for these stupid
1630  // special cases
1631  return CanonicalForm( f.isZero() && g.isZero() ? 0 : 1 );
1632  }
1633  else if ( what )
1634  return f.value->bgcdcoeff( g.value );
1635 
1636  int fLevel = f.value->level();
1637  int gLevel = g.value->level();
1638 
1639  // check levels
1640  if ( fLevel == gLevel )
1641  {
1642  fLevel = f.value->levelcoeff();
1643  gLevel = g.value->levelcoeff();
1644 
1645  // check levelcoeffs
1646  if ( fLevel == gLevel )
1647  return f.value->bgcdsame( g.value );
1648  else if ( fLevel < gLevel )
1649  return g.value->bgcdcoeff( f.value );
1650  else
1651  return f.value->bgcdcoeff( g.value );
1652  }
1653  else if ( fLevel < gLevel )
1654  return g.value->bgcdcoeff( f.value );
1655  else
1656  return f.value->bgcdcoeff( g.value );
1657 }
CF_NO_INLINE bool isZero() const
Definition: cf_inline.cc:372
virtual InternalCF * bgcdcoeff(const InternalCF *const)
Definition: int_cf.cc:139
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
const ring r
Definition: syzextra.cc:208
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
long imm2int(const InternalCF *const imm)
Definition: imm.h:66
#define swap(_i, _j)
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
virtual InternalCF * bgcdsame(const InternalCF *const) const
InternalCF * InternalCF::bgcdsame, bgcdcoeff ( const InternalCF * const )
Definition: int_cf.cc:132
const long INTMARK
Definition: imm.h:37
#define cf_glob_switches
CFSwitches cf_glob_switches;.
Definition: cf_switches.h:75
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ CFIterator

CFIterator
friend

Definition at line 195 of file canonicalform.h.

§ divrem [1/3]

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

Definition at line 969 of file canonicalform.cc.

970 {
971  InternalCF * qq = 0, * rr = 0;
972  int what = is_imm( f.value );
973  if ( what )
974  if ( is_imm( g.value ) ) {
975  if ( what == FFMARK )
976  imm_divrem_p( f.value, g.value, qq, rr );
977  else if ( what == GFMARK )
978  imm_divrem_gf( f.value, g.value, qq, rr );
979  else
980  imm_divrem( f.value, g.value, qq, rr );
981  }
982  else
983  g.value->divremcoeff( f.value, qq, rr, true );
984  else if ( (what=is_imm( g.value )) )
985  f.value->divremcoeff( g.value, qq, rr, false );
986  else if ( f.value->level() == g.value->level() )
987  if ( f.value->levelcoeff() == g.value->levelcoeff() )
988  f.value->divremsame( g.value, qq, rr );
989  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
990  f.value->divremcoeff( g.value, qq, rr, false );
991  else
992  g.value->divremcoeff( f.value, qq, rr, true );
993  else if ( f.value->level() > g.value->level() )
994  f.value->divremcoeff( g.value, qq, rr, false );
995  else
996  g.value->divremcoeff( f.value, qq, rr, true );
997  ASSERT( qq != 0 && rr != 0, "error in divrem" );
998  q = CanonicalForm( qq );
999  r = CanonicalForm( rr );
1000 }
const long GFMARK
Definition: imm.h:39
virtual void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_VOID("divremcoeff")
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual void divremsame(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_VOID("divremsame")

§ divrem [2/3]

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

Definition at line 969 of file canonicalform.cc.

970 {
971  InternalCF * qq = 0, * rr = 0;
972  int what = is_imm( f.value );
973  if ( what )
974  if ( is_imm( g.value ) ) {
975  if ( what == FFMARK )
976  imm_divrem_p( f.value, g.value, qq, rr );
977  else if ( what == GFMARK )
978  imm_divrem_gf( f.value, g.value, qq, rr );
979  else
980  imm_divrem( f.value, g.value, qq, rr );
981  }
982  else
983  g.value->divremcoeff( f.value, qq, rr, true );
984  else if ( (what=is_imm( g.value )) )
985  f.value->divremcoeff( g.value, qq, rr, false );
986  else if ( f.value->level() == g.value->level() )
987  if ( f.value->levelcoeff() == g.value->levelcoeff() )
988  f.value->divremsame( g.value, qq, rr );
989  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
990  f.value->divremcoeff( g.value, qq, rr, false );
991  else
992  g.value->divremcoeff( f.value, qq, rr, true );
993  else if ( f.value->level() > g.value->level() )
994  f.value->divremcoeff( g.value, qq, rr, false );
995  else
996  g.value->divremcoeff( f.value, qq, rr, true );
997  ASSERT( qq != 0 && rr != 0, "error in divrem" );
998  q = CanonicalForm( qq );
999  r = CanonicalForm( rr );
1000 }
const long GFMARK
Definition: imm.h:39
virtual void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_VOID("divremcoeff")
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual void divremsame(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_VOID("divremsame")

§ divrem [3/3]

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

Definition at line 969 of file canonicalform.cc.

970 {
971  InternalCF * qq = 0, * rr = 0;
972  int what = is_imm( f.value );
973  if ( what )
974  if ( is_imm( g.value ) ) {
975  if ( what == FFMARK )
976  imm_divrem_p( f.value, g.value, qq, rr );
977  else if ( what == GFMARK )
978  imm_divrem_gf( f.value, g.value, qq, rr );
979  else
980  imm_divrem( f.value, g.value, qq, rr );
981  }
982  else
983  g.value->divremcoeff( f.value, qq, rr, true );
984  else if ( (what=is_imm( g.value )) )
985  f.value->divremcoeff( g.value, qq, rr, false );
986  else if ( f.value->level() == g.value->level() )
987  if ( f.value->levelcoeff() == g.value->levelcoeff() )
988  f.value->divremsame( g.value, qq, rr );
989  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
990  f.value->divremcoeff( g.value, qq, rr, false );
991  else
992  g.value->divremcoeff( f.value, qq, rr, true );
993  else if ( f.value->level() > g.value->level() )
994  f.value->divremcoeff( g.value, qq, rr, false );
995  else
996  g.value->divremcoeff( f.value, qq, rr, true );
997  ASSERT( qq != 0 && rr != 0, "error in divrem" );
998  q = CanonicalForm( qq );
999  r = CanonicalForm( rr );
1000 }
const long GFMARK
Definition: imm.h:39
virtual void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_VOID("divremcoeff")
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual void divremsame(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_VOID("divremsame")

§ divremt [1/3]

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

Definition at line 1003 of file canonicalform.cc.

1004 {
1005  InternalCF * qq = 0, * rr = 0;
1006  int what = is_imm( f.value );
1007  bool result = true;
1008  if ( what )
1009  if ( is_imm( g.value ) ) {
1010  if ( what == FFMARK )
1011  imm_divrem_p( f.value, g.value, qq, rr );
1012  else if ( what == GFMARK )
1013  imm_divrem_gf( f.value, g.value, qq, rr );
1014  else
1015  imm_divrem( f.value, g.value, qq, rr );
1016  }
1017  else
1018  result = g.value->divremcoefft( f.value, qq, rr, true );
1019  else if ( (what=is_imm( g.value )) )
1020  result = f.value->divremcoefft( g.value, qq, rr, false );
1021  else if ( f.value->level() == g.value->level() )
1022  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1023  result = f.value->divremsamet( g.value, qq, rr );
1024  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1025  result = f.value->divremcoefft( g.value, qq, rr, false );
1026  else
1027  result = g.value->divremcoefft( f.value, qq, rr, true );
1028  else if ( f.value->level() > g.value->level() )
1029  result = f.value->divremcoefft( g.value, qq, rr, false );
1030  else
1031  result = g.value->divremcoefft( f.value, qq, rr, true );
1032  if ( result ) {
1033  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1034  q = CanonicalForm( qq );
1035  r = CanonicalForm( rr );
1036  }
1037  else {
1038  q = 0; r = 0;
1039  }
1040  return result;
1041 }
const long GFMARK
Definition: imm.h:39
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_BOOL("divremcoefft")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
virtual bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_BOOL("divremsamet")
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76

§ divremt [2/3]

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

Definition at line 1003 of file canonicalform.cc.

1004 {
1005  InternalCF * qq = 0, * rr = 0;
1006  int what = is_imm( f.value );
1007  bool result = true;
1008  if ( what )
1009  if ( is_imm( g.value ) ) {
1010  if ( what == FFMARK )
1011  imm_divrem_p( f.value, g.value, qq, rr );
1012  else if ( what == GFMARK )
1013  imm_divrem_gf( f.value, g.value, qq, rr );
1014  else
1015  imm_divrem( f.value, g.value, qq, rr );
1016  }
1017  else
1018  result = g.value->divremcoefft( f.value, qq, rr, true );
1019  else if ( (what=is_imm( g.value )) )
1020  result = f.value->divremcoefft( g.value, qq, rr, false );
1021  else if ( f.value->level() == g.value->level() )
1022  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1023  result = f.value->divremsamet( g.value, qq, rr );
1024  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1025  result = f.value->divremcoefft( g.value, qq, rr, false );
1026  else
1027  result = g.value->divremcoefft( f.value, qq, rr, true );
1028  else if ( f.value->level() > g.value->level() )
1029  result = f.value->divremcoefft( g.value, qq, rr, false );
1030  else
1031  result = g.value->divremcoefft( f.value, qq, rr, true );
1032  if ( result ) {
1033  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1034  q = CanonicalForm( qq );
1035  r = CanonicalForm( rr );
1036  }
1037  else {
1038  q = 0; r = 0;
1039  }
1040  return result;
1041 }
const long GFMARK
Definition: imm.h:39
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_BOOL("divremcoefft")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
virtual bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_BOOL("divremsamet")
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76

§ divremt [3/3]

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

Definition at line 1003 of file canonicalform.cc.

1004 {
1005  InternalCF * qq = 0, * rr = 0;
1006  int what = is_imm( f.value );
1007  bool result = true;
1008  if ( what )
1009  if ( is_imm( g.value ) ) {
1010  if ( what == FFMARK )
1011  imm_divrem_p( f.value, g.value, qq, rr );
1012  else if ( what == GFMARK )
1013  imm_divrem_gf( f.value, g.value, qq, rr );
1014  else
1015  imm_divrem( f.value, g.value, qq, rr );
1016  }
1017  else
1018  result = g.value->divremcoefft( f.value, qq, rr, true );
1019  else if ( (what=is_imm( g.value )) )
1020  result = f.value->divremcoefft( g.value, qq, rr, false );
1021  else if ( f.value->level() == g.value->level() )
1022  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1023  result = f.value->divremsamet( g.value, qq, rr );
1024  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1025  result = f.value->divremcoefft( g.value, qq, rr, false );
1026  else
1027  result = g.value->divremcoefft( f.value, qq, rr, true );
1028  else if ( f.value->level() > g.value->level() )
1029  result = f.value->divremcoefft( g.value, qq, rr, false );
1030  else
1031  result = g.value->divremcoefft( f.value, qq, rr, true );
1032  if ( result ) {
1033  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1034  q = CanonicalForm( qq );
1035  r = CanonicalForm( rr );
1036  }
1037  else {
1038  q = 0; r = 0;
1039  }
1040  return result;
1041 }
const long GFMARK
Definition: imm.h:39
const long FFMARK
Definition: imm.h:38
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:424
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
virtual bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool) PVIRT_BOOL("divremcoefft")
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
virtual bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&) PVIRT_BOOL("divremsamet")
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76

§ 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 1435 of file canonicalform.cc.

1436 {
1437  if ( lhs.value == rhs.value )
1438  return false;
1439  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1440  ASSERT( ! is_imm( rhs.value ) ||
1441  ! is_imm( lhs.value ) ||
1442  is_imm( rhs.value ) == is_imm( lhs.value ),
1443  "incompatible operands" );
1444  return true;
1445  }
1446  else if ( lhs.value->level() != rhs.value->level() )
1447  return true;
1448  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1449  return true;
1450  else return rhs.value->comparesame( lhs.value ) != 0;
1451 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1435 of file canonicalform.cc.

1436 {
1437  if ( lhs.value == rhs.value )
1438  return false;
1439  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1440  ASSERT( ! is_imm( rhs.value ) ||
1441  ! is_imm( lhs.value ) ||
1442  is_imm( rhs.value ) == is_imm( lhs.value ),
1443  "incompatible operands" );
1444  return true;
1445  }
1446  else if ( lhs.value->level() != rhs.value->level() )
1447  return true;
1448  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1449  return true;
1450  else return rhs.value->comparesame( lhs.value ) != 0;
1451 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 1435 of file canonicalform.cc.

1436 {
1437  if ( lhs.value == rhs.value )
1438  return false;
1439  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1440  ASSERT( ! is_imm( rhs.value ) ||
1441  ! is_imm( lhs.value ) ||
1442  is_imm( rhs.value ) == is_imm( lhs.value ),
1443  "incompatible operands" );
1444  return true;
1445  }
1446  else if ( lhs.value->level() != rhs.value->level() )
1447  return true;
1448  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1449  return true;
1450  else return rhs.value->comparesame( lhs.value ) != 0;
1451 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 {
440  CanonicalForm result( cf );
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 }
InternalCF * imm_neg_p(const InternalCF *const op)
Definition: imm.h:457
factory&#39;s main class
Definition: canonicalform.h:75
const long FFMARK
Definition: imm.h:38
InternalCF * imm_neg(const InternalCF *const op)
Definition: imm.h:451
InternalCF * imm_neg_gf(const InternalCF *const op)
Definition: imm.h:463
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
return result
Definition: facAbsBiFact.cc:76

§ 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 {
440  CanonicalForm result( cf );
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 }
InternalCF * imm_neg_p(const InternalCF *const op)
Definition: imm.h:457
factory&#39;s main class
Definition: canonicalform.h:75
const long FFMARK
Definition: imm.h:38
InternalCF * imm_neg(const InternalCF *const op)
Definition: imm.h:451
InternalCF * imm_neg_gf(const InternalCF *const op)
Definition: imm.h:463
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
return result
Definition: facAbsBiFact.cc:76

§ 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 {
440  CanonicalForm result( cf );
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 }
InternalCF * imm_neg_p(const InternalCF *const op)
Definition: imm.h:457
factory&#39;s main class
Definition: canonicalform.h:75
const long FFMARK
Definition: imm.h:38
InternalCF * imm_neg(const InternalCF *const op)
Definition: imm.h:451
InternalCF * imm_neg_gf(const InternalCF *const op)
Definition: imm.h:463
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
return result
Definition: facAbsBiFact.cc:76

§ operator< [1/3]

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

Definition at line 1529 of file canonicalform.cc.

1530 {
1531  int what = is_imm( rhs.value );
1532  if ( is_imm( lhs.value ) ) {
1533  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1534  if ( what == 0 )
1535  return rhs.value->comparecoeff( lhs.value ) > 0;
1536  else if ( what == INTMARK )
1537  return imm_cmp( lhs.value, rhs.value ) < 0;
1538  else if ( what == FFMARK )
1539  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1540  else
1541  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1542  }
1543  else if ( what )
1544  return lhs.value->comparecoeff( rhs.value ) < 0;
1545  else if ( lhs.value->level() == rhs.value->level() )
1546  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1547  return lhs.value->comparesame( rhs.value ) < 0;
1548  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1549  return lhs.value->comparecoeff( rhs.value ) < 0;
1550  else
1551  return rhs.value->comparecoeff( lhs.value ) > 0;
1552  else
1553  return lhs.value->level() < rhs.value->level();
1554 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ operator< [2/3]

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

Definition at line 1529 of file canonicalform.cc.

1530 {
1531  int what = is_imm( rhs.value );
1532  if ( is_imm( lhs.value ) ) {
1533  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1534  if ( what == 0 )
1535  return rhs.value->comparecoeff( lhs.value ) > 0;
1536  else if ( what == INTMARK )
1537  return imm_cmp( lhs.value, rhs.value ) < 0;
1538  else if ( what == FFMARK )
1539  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1540  else
1541  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1542  }
1543  else if ( what )
1544  return lhs.value->comparecoeff( rhs.value ) < 0;
1545  else if ( lhs.value->level() == rhs.value->level() )
1546  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1547  return lhs.value->comparesame( rhs.value ) < 0;
1548  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1549  return lhs.value->comparecoeff( rhs.value ) < 0;
1550  else
1551  return rhs.value->comparecoeff( lhs.value ) > 0;
1552  else
1553  return lhs.value->level() < rhs.value->level();
1554 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ operator< [3/3]

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

Definition at line 1529 of file canonicalform.cc.

1530 {
1531  int what = is_imm( rhs.value );
1532  if ( is_imm( lhs.value ) ) {
1533  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1534  if ( what == 0 )
1535  return rhs.value->comparecoeff( lhs.value ) > 0;
1536  else if ( what == INTMARK )
1537  return imm_cmp( lhs.value, rhs.value ) < 0;
1538  else if ( what == FFMARK )
1539  return imm_cmp_p( lhs.value, rhs.value ) < 0;
1540  else
1541  return imm_cmp_gf( lhs.value, rhs.value ) < 0;
1542  }
1543  else if ( what )
1544  return lhs.value->comparecoeff( rhs.value ) < 0;
1545  else if ( lhs.value->level() == rhs.value->level() )
1546  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1547  return lhs.value->comparesame( rhs.value ) < 0;
1548  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1549  return lhs.value->comparecoeff( rhs.value ) < 0;
1550  else
1551  return rhs.value->comparecoeff( lhs.value ) > 0;
1552  else
1553  return lhs.value->level() < rhs.value->level();
1554 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ operator<<

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

Definition at line 1794 of file canonicalform.cc.

1795 {
1796  cf.print( os, "" );
1797  return os;
1798 }
void print(OSTREAM &, char *) const
input/output

§ 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 `CanonicalFormisZero()' 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 1410 of file canonicalform.cc.

1411 {
1412  if ( lhs.value == rhs.value )
1413  return true;
1414  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1415  ASSERT( ! is_imm( rhs.value ) ||
1416  ! is_imm( lhs.value ) ||
1417  is_imm( rhs.value ) == is_imm( lhs.value ),
1418  "incompatible operands" );
1419  return false;
1420  }
1421  else if ( lhs.value->level() != rhs.value->level() )
1422  return false;
1423  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1424  return false;
1425  else
1426  return rhs.value->comparesame( lhs.value ) == 0;
1427 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 `CanonicalFormisZero()' 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 1410 of file canonicalform.cc.

1411 {
1412  if ( lhs.value == rhs.value )
1413  return true;
1414  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1415  ASSERT( ! is_imm( rhs.value ) ||
1416  ! is_imm( lhs.value ) ||
1417  is_imm( rhs.value ) == is_imm( lhs.value ),
1418  "incompatible operands" );
1419  return false;
1420  }
1421  else if ( lhs.value->level() != rhs.value->level() )
1422  return false;
1423  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1424  return false;
1425  else
1426  return rhs.value->comparesame( lhs.value ) == 0;
1427 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 `CanonicalFormisZero()' 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 1410 of file canonicalform.cc.

1411 {
1412  if ( lhs.value == rhs.value )
1413  return true;
1414  else if ( is_imm( rhs.value ) || is_imm( lhs.value ) ) {
1415  ASSERT( ! is_imm( rhs.value ) ||
1416  ! is_imm( lhs.value ) ||
1417  is_imm( rhs.value ) == is_imm( lhs.value ),
1418  "incompatible operands" );
1419  return false;
1420  }
1421  else if ( lhs.value->level() != rhs.value->level() )
1422  return false;
1423  else if ( lhs.value->levelcoeff() != rhs.value->levelcoeff() )
1424  return false;
1425  else
1426  return rhs.value->comparesame( lhs.value ) == 0;
1427 }
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
#define ASSERT(expression, message)
Definition: cf_assert.h:99

§ 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 `InternalPolyoperator <()'.

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 1498 of file canonicalform.cc.

1499 {
1500  int what = is_imm( rhs.value );
1501  if ( is_imm( lhs.value ) ) {
1502  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1503  if ( what == 0 )
1504  return rhs.value->comparecoeff( lhs.value ) < 0;
1505  else if ( what == INTMARK )
1506  return imm_cmp( lhs.value, rhs.value ) > 0;
1507  else if ( what == FFMARK )
1508  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1509  else
1510  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1511  }
1512  else if ( what )
1513  return lhs.value->comparecoeff( rhs.value ) > 0;
1514  else if ( lhs.value->level() == rhs.value->level() )
1515  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1516  return lhs.value->comparesame( rhs.value ) > 0;
1517  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1518  return lhs.value->comparecoeff( rhs.value ) > 0;
1519  else
1520  return rhs.value->comparecoeff( lhs.value ) < 0;
1521  else
1522  return lhs.value->level() > rhs.value->level();
1523 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ 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 `InternalPolyoperator <()'.

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 1498 of file canonicalform.cc.

1499 {
1500  int what = is_imm( rhs.value );
1501  if ( is_imm( lhs.value ) ) {
1502  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1503  if ( what == 0 )
1504  return rhs.value->comparecoeff( lhs.value ) < 0;
1505  else if ( what == INTMARK )
1506  return imm_cmp( lhs.value, rhs.value ) > 0;
1507  else if ( what == FFMARK )
1508  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1509  else
1510  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1511  }
1512  else if ( what )
1513  return lhs.value->comparecoeff( rhs.value ) > 0;
1514  else if ( lhs.value->level() == rhs.value->level() )
1515  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1516  return lhs.value->comparesame( rhs.value ) > 0;
1517  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1518  return lhs.value->comparecoeff( rhs.value ) > 0;
1519  else
1520  return rhs.value->comparecoeff( lhs.value ) < 0;
1521  else
1522  return lhs.value->level() > rhs.value->level();
1523 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ 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 `InternalPolyoperator <()'.

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 1498 of file canonicalform.cc.

1499 {
1500  int what = is_imm( rhs.value );
1501  if ( is_imm( lhs.value ) ) {
1502  ASSERT( ! what || (what == is_imm( lhs.value )), "incompatible operands" );
1503  if ( what == 0 )
1504  return rhs.value->comparecoeff( lhs.value ) < 0;
1505  else if ( what == INTMARK )
1506  return imm_cmp( lhs.value, rhs.value ) > 0;
1507  else if ( what == FFMARK )
1508  return imm_cmp_p( lhs.value, rhs.value ) > 0;
1509  else
1510  return imm_cmp_gf( lhs.value, rhs.value ) > 0;
1511  }
1512  else if ( what )
1513  return lhs.value->comparecoeff( rhs.value ) > 0;
1514  else if ( lhs.value->level() == rhs.value->level() )
1515  if ( lhs.value->levelcoeff() == rhs.value->levelcoeff() )
1516  return lhs.value->comparesame( rhs.value ) > 0;
1517  else if ( lhs.value->levelcoeff() > rhs.value->levelcoeff() )
1518  return lhs.value->comparecoeff( rhs.value ) > 0;
1519  else
1520  return rhs.value->comparecoeff( lhs.value ) < 0;
1521  else
1522  return lhs.value->level() > rhs.value->level();
1523 }
const long FFMARK
Definition: imm.h:38
int imm_cmp_p(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:241
virtual int comparesame(InternalCF *) PVIRT_INT("comparesame")
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:230
virtual int comparecoeff(InternalCF *) PVIRT_INT("comparecoeff")
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
const long INTMARK
Definition: imm.h:37
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int imm_cmp_gf(const InternalCF *const lhs, const InternalCF *const rhs)
Definition: imm.h:252

§ operator>>

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

Definition at line 1801 of file canonicalform.cc.

1802 {
1803  cf = readCF( is );
1804  return is;
1805 }
CanonicalForm readCF(ISTREAM &)
Definition: readcf.cc:1616

§ 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 1045 of file canonicalform.cc.

1046 {
1047  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1048  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1049  fail= false;
1050  InternalCF * qq = 0, * rr = 0;
1051  int what = is_imm( f.value );
1052  bool result = true;
1053  if ( what )
1054  if ( is_imm( g.value ) ) {
1055  if ( what == FFMARK )
1056  imm_divrem_p( f.value, g.value, qq, rr );
1057  else if ( what == GFMARK )
1058  imm_divrem_gf( f.value, g.value, qq, rr );
1059  }
1060  else
1061  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1062  else if ( (what=is_imm( g.value )) )
1063  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1064  else if ( f.value->level() == g.value->level() )
1065  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1066  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1067  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1068  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1069  else
1070  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1071  else if ( f.value->level() > g.value->level() )
1072  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1073  else
1074  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1075  if (fail)
1076  {
1077  q= 0;
1078  r= 0;
1079  return false;
1080  }
1081  if ( result ) {
1082  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1083  q = CanonicalForm( qq );
1084  r = CanonicalForm( rr );
1085  q= reduce (q, M);
1086  r= reduce (r, M);
1087  }
1088  else {
1089  q = 0; r = 0;
1090  }
1091  return result;
1092 }
const long GFMARK
Definition: imm.h:39
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
const long FFMARK
Definition: imm.h:38
int getCharacteristic()
Definition: cf_char.cc:51
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
virtual bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_cf.cc:200
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_cf.cc:193
return result
Definition: facAbsBiFact.cc:76

§ 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 1045 of file canonicalform.cc.

1046 {
1047  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1048  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1049  fail= false;
1050  InternalCF * qq = 0, * rr = 0;
1051  int what = is_imm( f.value );
1052  bool result = true;
1053  if ( what )
1054  if ( is_imm( g.value ) ) {
1055  if ( what == FFMARK )
1056  imm_divrem_p( f.value, g.value, qq, rr );
1057  else if ( what == GFMARK )
1058  imm_divrem_gf( f.value, g.value, qq, rr );
1059  }
1060  else
1061  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1062  else if ( (what=is_imm( g.value )) )
1063  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1064  else if ( f.value->level() == g.value->level() )
1065  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1066  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1067  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1068  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1069  else
1070  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1071  else if ( f.value->level() > g.value->level() )
1072  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1073  else
1074  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1075  if (fail)
1076  {
1077  q= 0;
1078  r= 0;
1079  return false;
1080  }
1081  if ( result ) {
1082  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1083  q = CanonicalForm( qq );
1084  r = CanonicalForm( rr );
1085  q= reduce (q, M);
1086  r= reduce (r, M);
1087  }
1088  else {
1089  q = 0; r = 0;
1090  }
1091  return result;
1092 }
const long GFMARK
Definition: imm.h:39
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
const long FFMARK
Definition: imm.h:38
int getCharacteristic()
Definition: cf_char.cc:51
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
virtual bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_cf.cc:200
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_cf.cc:193
return result
Definition: facAbsBiFact.cc:76

§ 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 1045 of file canonicalform.cc.

1046 {
1047  ASSERT (getCharacteristic() > 0, "expected positive characteristic");
1048  ASSERT (!getReduce (M.mvar()), "do not reduce modulo M");
1049  fail= false;
1050  InternalCF * qq = 0, * rr = 0;
1051  int what = is_imm( f.value );
1052  bool result = true;
1053  if ( what )
1054  if ( is_imm( g.value ) ) {
1055  if ( what == FFMARK )
1056  imm_divrem_p( f.value, g.value, qq, rr );
1057  else if ( what == GFMARK )
1058  imm_divrem_gf( f.value, g.value, qq, rr );
1059  }
1060  else
1061  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1062  else if ( (what=is_imm( g.value )) )
1063  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1064  else if ( f.value->level() == g.value->level() )
1065  if ( f.value->levelcoeff() == g.value->levelcoeff() )
1066  result = f.value->tryDivremsamet( g.value, qq, rr, M, fail );
1067  else if ( f.value->levelcoeff() > g.value->levelcoeff() )
1068  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1069  else
1070  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1071  else if ( f.value->level() > g.value->level() )
1072  result = f.value->tryDivremcoefft( g.value, qq, rr, false, M, fail );
1073  else
1074  result = g.value->tryDivremcoefft( f.value, qq, rr, true, M, fail );
1075  if (fail)
1076  {
1077  q= 0;
1078  r= 0;
1079  return false;
1080  }
1081  if ( result ) {
1082  ASSERT( qq != 0 && rr != 0, "error in divrem" );
1083  q = CanonicalForm( qq );
1084  r = CanonicalForm( rr );
1085  q= reduce (q, M);
1086  r= reduce (r, M);
1087  }
1088  else {
1089  q = 0; r = 0;
1090  }
1091  return result;
1092 }
const long GFMARK
Definition: imm.h:39
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
const long FFMARK
Definition: imm.h:38
int getCharacteristic()
Definition: cf_char.cc:51
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
virtual int levelcoeff() const
Definition: int_cf.h:64
virtual int level() const
Definition: int_cf.h:63
void imm_divrem_gf(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:442
virtual bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_cf.cc:200
bool getReduce(const Variable &alpha)
Definition: variable.cc:232
Variable mvar() const
mvar() returns the main variable of CO or Variable() if CO is in a base domain.
CF_INLINE CanonicalForm()
CF_INLINE CanonicalForm::CanonicalForm ()
Definition: cf_inline.cc:126
InternalCF * value
Definition: canonicalform.h:81
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:60
void imm_divrem_p(const InternalCF *const lhs, const InternalCF *const rhs, InternalCF *&q, InternalCF *&r)
Definition: imm.h:436
#define ASSERT(expression, message)
Definition: cf_assert.h:99
virtual bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_cf.cc:193
return result
Definition: facAbsBiFact.cc:76

Field Documentation

§ value

InternalCF * CanonicalForm::value
private

Definition at line 81 of file canonicalform.h.


The documentation for this class was generated from the following files: