1 /* emacs edit mode for this file is -*- C++ -*- */ 2 3 /** 4 * @file int_cf.h 5 * 6 * Factory's internal CanonicalForm's 7 **/ 8 #ifndef INCL_INT_CF_H 9 #define INCL_INT_CF_H 10 11 // #include "config.h" 12 13 #ifndef NOSTREAMIO 14 #ifdef HAVE_IOSTREAM 15 #include <iostream> 16 #define OSTREAM std::ostream 17 #elif defined(HAVE_IOSTREAM_H) 18 #include <iostream.h> 19 #define OSTREAM ostream 20 #endif 21 #endif /* NOSTREAMIO */ 22 23 #include "cf_assert.h" 24 25 #include "cf_defs.h" 26 #include "variable.h" 27 28 #ifdef HAVE_OMALLOC 29 #ifndef XMEMORY_H 30 #include "omalloc/omallocClass.h" 31 #endif 32 #endif 33 34 class CanonicalForm; 35 36 /** 37 * virtual class for internal CanonicalForm's 38 * 39 * InternalCF will become an InternalPoly, InternalInteger, InternalRational 40 **/ 41 class InternalCF 42 #ifdef HAVE_OMALLOC 43 #ifndef XMEMORY_H 44 : public omallocClass 45 #endif 46 #endif 47 { 48 private: 49 int refCount; 50 protected: getRefCount()51 int getRefCount() { return refCount; }; incRefCount()52 void incRefCount() { refCount++; }; decRefCount()53 int decRefCount() { return --refCount; }; 54 public: InternalCF()55 InternalCF() { refCount = 1; }; InternalCF(const InternalCF &)56 InternalCF( const InternalCF& ) 57 { 58 ASSERT( 0, "ups there is something wrong in your code"); 59 }; ~InternalCF()60 virtual ~InternalCF() {}; deleteObject()61 int deleteObject() { return decRefCount() == 0; } copyObject()62 InternalCF* copyObject() { incRefCount(); return this; } 63 virtual InternalCF* deepCopyObject() const PVIRT_INTCF("deepCopyObject"); 64 virtual const char * classname() const PVIRT_CHARCC("classname"); 65 virtual InternalCF* genZero() PVIRT_INTCF("genZero"); 66 virtual InternalCF* genOne() PVIRT_INTCF("genOne"); level()67 virtual int level() const { return LEVELBASE; } levelcoeff()68 virtual int levelcoeff() const { return UndefinedDomain; } type()69 virtual int type() const { return UndefinedDomain; } variable()70 virtual Variable variable() const { return Variable(); } 71 #ifndef NOSTREAMIO 72 virtual void print( OSTREAM&, char* ) PVIRT_VOID("print"); 73 #endif /* NOSTREAMIO */ inBaseDomain()74 virtual bool inBaseDomain() const { return true; } inExtension()75 virtual bool inExtension() const { return false; } inCoeffDomain()76 virtual bool inCoeffDomain() const { return true; } inPolyDomain()77 virtual bool inPolyDomain() const { return false; } inQuotDomain()78 virtual bool inQuotDomain() const { return false; } 79 virtual bool isZero() const; 80 virtual bool isOne() const; isUnivariate()81 virtual bool isUnivariate() const { return false; } 82 virtual long intval() const; intmod(int)83 virtual int intmod( int ) const { return 0; } 84 virtual int sign() const PVIRT_INT("sign"); 85 86 virtual InternalCF* num(); 87 virtual InternalCF* den(); 88 89 virtual InternalCF* neg() PVIRT_INTCF("neg"); 90 virtual InternalCF* invert(); // semantically const, changes refCount 91 virtual InternalCF* tryInvert( const CanonicalForm&, bool& ); 92 virtual int comparesame ( InternalCF * ) PVIRT_INT("comparesame"); 93 virtual int comparecoeff ( InternalCF * ) PVIRT_INT("comparecoeff"); 94 95 virtual InternalCF* addsame( InternalCF* ) PVIRT_INTCF("addsame"); 96 virtual InternalCF* subsame( InternalCF* ) PVIRT_INTCF("subsame"); 97 virtual InternalCF* mulsame( InternalCF* ) PVIRT_INTCF("mulsame"); 98 virtual InternalCF* tryMulsame( InternalCF*, const CanonicalForm& ); 99 virtual InternalCF* dividesame( InternalCF* ) PVIRT_INTCF("dividesame"); 100 virtual InternalCF* modulosame( InternalCF* ) PVIRT_INTCF("modulosame"); 101 virtual InternalCF* divsame( InternalCF* ) PVIRT_INTCF("divsame"); 102 virtual InternalCF* tryDivsame ( InternalCF* , const CanonicalForm&, bool& ); 103 virtual InternalCF* modsame( InternalCF* ) PVIRT_INTCF("modsame"); 104 virtual void divremsame( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_VOID("divremsame"); 105 virtual bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& ) PVIRT_BOOL("divremsamet"); 106 virtual bool tryDivremsamet ( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& ); 107 108 virtual InternalCF* addcoeff( InternalCF* ) PVIRT_INTCF("addcoeff"); 109 virtual InternalCF* subcoeff( InternalCF*, bool ) PVIRT_INTCF("subcoeff"); 110 virtual InternalCF* mulcoeff( InternalCF* ) PVIRT_INTCF("mulcoeff"); 111 virtual InternalCF* dividecoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff"); 112 virtual InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& ); 113 virtual InternalCF* modulocoeff( InternalCF*, bool ) PVIRT_INTCF("dividecoeff"); 114 virtual InternalCF* divcoeff( InternalCF*, bool ) PVIRT_INTCF("divcoeff"); 115 virtual InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& ); 116 virtual InternalCF* modcoeff( InternalCF*, bool ) PVIRT_INTCF("modcoeff"); 117 virtual void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_VOID("divremcoeff"); 118 virtual bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool ) PVIRT_BOOL("divremcoefft"); 119 virtual bool tryDivremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& ); 120 121 virtual InternalCF * bgcdsame ( const InternalCF * const ) const; 122 virtual InternalCF * bgcdcoeff ( const InternalCF * const ); // semantically const, changes refcount 123 124 virtual InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & ); // semantically const, changes refcount 125 virtual InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & ); // semantically const, changes refcount 126 127 virtual InternalCF* sqrt(); 128 virtual int ilog2(); 129 virtual CanonicalForm lc(); 130 virtual CanonicalForm Lc(); 131 virtual CanonicalForm LC(); 132 virtual CanonicalForm coeff( int i ); 133 virtual int degree(); 134 virtual int taildegree(); 135 virtual CanonicalForm tailcoeff(); 136 }; 137 138 #endif /* ! INCL_INT_CF_H */ 139