int_poly.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_INT_POLY_H
4 #define INCL_INT_POLY_H
5 
6 /**
7  * @file int_poly.h
8  *
9  * Factory's internal polynomials
10 **/
11 
12 // #include "config.h"
13 
14 #ifndef NOSTREAMIO
15 #ifdef HAVE_IOSTREAM
16 #include <iostream>
17 #define OSTREAM std::ostream
18 #elif defined(HAVE_IOSTREAM_H)
19 #include <iostream.h>
20 #define OSTREAM ostream
21 #endif
22 #endif /* NOSTREAMIO */
23 
24 #include "cf_defs.h"
25 #include "int_cf.h"
26 #include "variable.h"
27 #include "canonicalform.h"
28 
29 #ifdef HAVE_OMALLOC
30 #ifndef OM_NDEBUG
31 #define OM_NDEBUG
32 #endif
33 # include <omalloc/omalloc.h>
34 #endif
35 
36 class term {
37 private:
40  int exp;
41 #ifdef HAVE_OMALLOC
42  static const omBin term_bin;
43 #endif
44 public:
45  term() : next(0), coeff(0), exp(0) {}
46  term( term * n, const CanonicalForm & c, int e ) : next(n), coeff(c), exp(e) {}
47  friend class InternalPoly;
48  friend class CFIterator;
49 #ifdef HAVE_OMALLOC
50  void* operator new(size_t)
51  {
52  void* addr;
53  omTypeAllocBin(void*, addr, term_bin);
54  return addr;
55  }
56  void operator delete(void* addr, size_t)
57  {
58  omFreeBin(addr, term_bin);
59  }
60 #endif
61 };
62 
63 typedef term * termList;
64 
65 
66 /**
67  * factory's class for polynomials
68  *
69  * polynomials are represented as a linked list termList, factory
70  * uses a sparse distributive representation of polynomials, i.e. each poly
71  * is viewed as a univariate poly in its main variable CanonicalForm::mvar()
72  * over a (polynomial) ring
73 **/
74 class InternalPoly : public InternalCF {
75 private:
79 
80  static termList copyTermList ( termList, termList&, bool negate = false );
82  static void freeTermList ( termList );
83  static void negateTermList ( termList );
84  static termList addTermList ( termList, termList, termList&, bool negate );
85  static void mulTermList ( termList, const CanonicalForm& , const int );
87  static termList divTermList ( termList, const CanonicalForm&, termList& );
88  static termList tryDivTermList ( termList, const CanonicalForm&, termList&, const CanonicalForm&, bool& );
89  static termList modTermList ( termList, const CanonicalForm&, termList& );
90  static void appendTermList ( termList&, termList&, const CanonicalForm&, const int );
91  static termList mulAddTermList ( termList theList, termList aList, const CanonicalForm & c, const int exp, termList & lastTerm, bool negate );
92  static termList reduceTermList ( termList first, termList redterms, termList & last );
93 public:
94  InternalPoly();
95  InternalPoly( const Variable & v, const int e, const CanonicalForm& c );
96  InternalPoly( const InternalPoly& );
97  ~InternalPoly();
98  InternalCF* deepCopyObject() const;
99  const char * classname() const { return "InternalPoly"; }
100  int level() const { return var.level(); }
101  Variable variable() const { return var; }
102  int degree();
103  CanonicalForm lc();
104  CanonicalForm Lc();
105  CanonicalForm LC();
106  int taildegree();
108  CanonicalForm coeff( int i );
109 #ifndef NOSTREAMIO
110  void print( OSTREAM&, char* );
111 #endif /* NOSTREAMIO */
112  bool inBaseDomain() const { return false; }
113  bool inExtension() const { return var.level() < 0; }
114  bool inCoeffDomain() const { return var.level() < 0; }
115  bool inPolyDomain() const { return var.level() > 0; }
116  bool inQuotDomain() const { return false; }
117  InternalCF* genZero();
118  InternalCF* genOne();
119 
120  bool isUnivariate() const;
121 
122  InternalCF* neg();
123  InternalCF* invert();
124  InternalCF* tryInvert( const CanonicalForm&, bool& );
125  int comparesame ( InternalCF* );
126 
134  InternalCF* tryDivsame ( InternalCF*, const CanonicalForm&, bool& );
138  bool tryDivremsamet( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
139 
140  int comparecoeff ( InternalCF* );
141 
143  InternalCF* subcoeff( InternalCF*, bool );
145  InternalCF* dividecoeff( InternalCF*, bool );
146  InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
147  InternalCF* modulocoeff( InternalCF*, bool );
148  InternalCF* divcoeff( InternalCF*, bool );
149  InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
150  InternalCF* modcoeff( InternalCF*, bool );
151  void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
152  bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
153  bool tryDivremcoefft ( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
154 
155  int sign() const;
156 
157 #ifdef HAVE_OMALLOC
158  static const omBin InternalPoly_bin;
159  void* operator new(size_t)
160  {
161  void* addr;
162  omTypeAllocBin(void*, addr, InternalPoly_bin);
163  return addr;
164  }
165  void operator delete(void* addr, size_t)
166  {
167  omFreeBin(addr, InternalPoly_bin);
168  }
169 #endif
170  friend class CFIterator;
171 };
172 
173 #endif /* ! INCL_INT_POLY_H */
InternalCF * neg()
InternalCF * InternalPoly::neg ()
Definition: int_poly.cc:235
static void mulTermList(termList, const CanonicalForm &, const int)
Definition: int_poly.cc:2008
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalPoly.
Definition: int_poly.cc:994
InternalCF * mulsame(InternalCF *)
Definition: int_poly.cc:370
int level() const
Definition: variable.h:49
static void negateTermList(termList)
Definition: int_poly.cc:1915
static termList modTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2108
term * termList
Definition: int_poly.h:63
omBin_t * omBin
Definition: omStructs.h:12
Variable variable() const
Definition: int_poly.h:101
InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_poly.cc:588
Definition: int_poly.h:36
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_poly.cc:1221
factory's class for variables
Definition: variable.h:32
CanonicalForm LC()
Definition: int_poly.cc:142
static void appendTermList(termList &, termList &, const CanonicalForm &, const int)
Definition: int_poly.cc:2137
int exp
Definition: int_poly.h:40
const char * classname() const
Definition: int_poly.h:99
static poly last
Definition: hdegree.cc:1075
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
InternalCF * divsame(InternalCF *)
Definition: int_poly.cc:502
static termList divideTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2019
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1656
factory's main class
Definition: canonicalform.h:75
CanonicalForm tailcoeff()
CanonicalForm InternalPoly::tailcoeff (), int InternalPoly::taildegree ()
Definition: int_poly.cc:151
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_poly.cc:1578
bool inQuotDomain() const
Definition: int_poly.h:116
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:821
static const omBin InternalPoly_bin
Definition: int_poly.h:158
virtual class for internal CanonicalForm's
Definition: int_cf.h:39
bool isUnivariate() const
Definition: int_poly.cc:88
CanonicalForm Lc()
Definition: int_poly.cc:133
InternalCF * invert()
Definition: int_poly.cc:251
InternalCF * tryInvert(const CanonicalForm &, bool &)
Definition: int_poly.cc:268
InternalCF * genZero()
Definition: int_poly.cc:76
InternalCF * subsame(InternalCF *)
Definition: int_poly.cc:330
CanonicalForm coeff
Definition: int_poly.h:39
term * next
Definition: int_poly.h:38
termList lastTerm
Definition: int_poly.h:76
InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1307
InternalCF * genOne()
Definition: int_poly.cc:82
int sign() const
int InternalPoly::sign () const
Definition: int_poly.cc:114
InternalCF * dividesame(InternalCF *)
Definition: int_poly.cc:495
CanonicalForm coeff(int i)
CanonicalForm InternalPoly::coeff ( int i )
Definition: int_poly.cc:166
static termList divTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2048
static termList deepCopyTermList(termList, termList &)
Definition: int_poly.cc:1877
Variable var
Definition: int_poly.h:77
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1693
InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1479
InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
Definition: int_poly.cc:432
static termList addTermList(termList, termList, termList &, bool negate)
Definition: int_poly.cc:1926
term()
Definition: int_poly.h:45
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:769
bool inBaseDomain() const
Definition: int_poly.h:112
factory's class for polynomials
Definition: int_poly.h:74
int i
Definition: cfEzgcd.cc:123
bool inExtension() const
Definition: int_poly.h:113
InternalCF * modulosame(InternalCF *)
Definition: int_poly.cc:691
factory switches.
InternalCF * modsame(InternalCF *)
Definition: int_poly.cc:697
InternalCF * deepCopyObject() const
Definition: int_poly.cc:68
static void freeTermList(termList)
Definition: int_poly.cc:1902
void print(OSTREAM &, char *)
Definition: int_poly.cc:183
static termList tryDivTermList(termList, const CanonicalForm &, termList &, const CanonicalForm &, bool &)
Definition: int_poly.cc:2077
int taildegree()
Definition: int_poly.cc:157
bool inPolyDomain() const
Definition: int_poly.h:115
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
static termList mulAddTermList(termList theList, termList aList, const CanonicalForm &c, const int exp, termList &lastTerm, bool negate)
Definition: int_poly.cc:2152
static const omBin term_bin
Definition: int_poly.h:42
operations on variables
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_poly.cc:1592
static termList copyTermList(termList, termList &, bool negate=false)
Definition: int_poly.cc:1834
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_poly.cc:1403
int level() const
Definition: int_poly.h:100
bool inCoeffDomain() const
Definition: int_poly.h:114
int degree()
int InternalPoly::degree ()
Definition: int_poly.cc:104
InternalCF * addsame(InternalCF *)
Definition: int_poly.cc:290
term(term *n, const CanonicalForm &c, int e)
Definition: int_poly.h:46
static termList reduceTermList(termList first, termList redterms, termList &last)
Definition: int_poly.cc:2236
bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_poly.cc:887
#define OSTREAM
Definition: int_poly.h:17
Factory's internal CanonicalForm's.
p exp[i]
Definition: DebugPrint.cc:39
CanonicalForm lc()
Definition: int_poly.cc:124
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
termList firstTerm
Definition: int_poly.h:76
bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1759
InternalCF * mulcoeff(InternalCF *)
Definition: int_poly.cc:1185
Header for factory's main class CanonicalForm.
int comparecoeff(InternalCF *)
comparecoeff() always returns 1 since CO is defined to be larger than anything which is a coefficient...
Definition: int_poly.cc:1036
InternalCF * addcoeff(InternalCF *)
Definition: int_poly.cc:1042
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_poly.cc:1099