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 # include <omalloc/omalloc.h>
31 #endif
32 
33 class term {
34 private:
37  int exp;
38 #ifdef HAVE_OMALLOC
39  static const omBin term_bin;
40 #endif
41 public:
42  term() : next(0), coeff(0), exp(0) {}
43  term( term * n, const CanonicalForm & c, int e ) : next(n), coeff(c), exp(e) {}
44  friend class InternalPoly;
45  friend class CFIterator;
46 #ifdef HAVE_OMALLOC
47  void* operator new(size_t)
48  {
49  void* addr;
50  omTypeAllocBin(void*, addr, term_bin);
51  return addr;
52  }
53  void operator delete(void* addr, size_t)
54  {
55  omFreeBin(addr, term_bin);
56  }
57 #endif
58 };
59 
60 typedef term * termList;
61 
62 
63 /**
64  * factory's class for polynomials
65  *
66  * polynomials are represented as a linked list termList, factory
67  * uses a sparse distributive representation of polynomials, i.e. each poly
68  * is viewed as a univariate poly in its main variable CanonicalForm::mvar()
69  * over a (polynomial) ring
70 **/
71 class InternalPoly : public InternalCF {
72 private:
73  termList firstTerm, lastTerm;
76 
77  static termList copyTermList ( termList, termList&, bool negate = false );
78  static termList deepCopyTermList ( termList, termList& );
79  static void freeTermList ( termList );
80  static void negateTermList ( termList );
81  static termList addTermList ( termList, termList, termList&, bool negate );
82  static void mulTermList ( termList, const CanonicalForm& , const int );
83  static termList divideTermList ( termList, const CanonicalForm&, termList& );
84  static termList divTermList ( termList, const CanonicalForm&, termList& );
85  static termList tryDivTermList ( termList, const CanonicalForm&, termList&, const CanonicalForm&, bool& );
86  static termList modTermList ( termList, const CanonicalForm&, termList& );
87  static void appendTermList ( termList&, termList&, const CanonicalForm&, const int );
88  static termList mulAddTermList ( termList theList, termList aList, const CanonicalForm & c, const int exp, termList & lastTerm, bool negate );
89  static termList reduceTermList ( termList first, termList redterms, termList & last );
90 public:
91  InternalPoly();
92  InternalPoly( const Variable & v, const int e, const CanonicalForm& c );
93  InternalPoly( const InternalPoly& );
94  ~InternalPoly();
95  InternalCF* deepCopyObject() const;
96  const char * classname() const { return "InternalPoly"; }
97  int level() const { return var.level(); }
98  Variable variable() const { return var; }
99  int degree();
100  CanonicalForm lc();
101  CanonicalForm Lc();
102  CanonicalForm LC();
103  int taildegree();
105  CanonicalForm coeff( int i );
106 #ifndef NOSTREAMIO
107  void print( OSTREAM&, char* );
108 #endif /* NOSTREAMIO */
109  bool inBaseDomain() const { return false; }
110  bool inExtension() const { return var.level() < 0; }
111  bool inCoeffDomain() const { return var.level() < 0; }
112  bool inPolyDomain() const { return var.level() > 0; }
113  bool inQuotDomain() const { return false; }
114  InternalCF* genZero();
115  InternalCF* genOne();
116 
117  bool isUnivariate() const;
118 
119  InternalCF* neg();
120  InternalCF* invert();
121  InternalCF* tryInvert( const CanonicalForm&, bool& );
122  int comparesame ( InternalCF* );
123 
124  InternalCF* addsame( InternalCF* );
125  InternalCF* subsame( InternalCF* );
126  InternalCF* mulsame( InternalCF* );
127  InternalCF* tryMulsame ( InternalCF*, const CanonicalForm&);
128  InternalCF* dividesame( InternalCF* );
129  InternalCF* modulosame( InternalCF* );
130  InternalCF* divsame( InternalCF* );
131  InternalCF* tryDivsame ( InternalCF*, const CanonicalForm&, bool& );
132  InternalCF* modsame( InternalCF* );
133  void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
134  bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
135  bool tryDivremsamet( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
136 
137  int comparecoeff ( InternalCF* );
138 
139  InternalCF* addcoeff( InternalCF* );
140  InternalCF* subcoeff( InternalCF*, bool );
141  InternalCF* mulcoeff( InternalCF* );
142  InternalCF* dividecoeff( InternalCF*, bool );
143  InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
144  InternalCF* modulocoeff( InternalCF*, bool );
145  InternalCF* divcoeff( InternalCF*, bool );
146  InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
147  InternalCF* modcoeff( InternalCF*, bool );
148  void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
149  bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
150  bool tryDivremcoefft ( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
151 
152  int sign() const;
153 
154 #ifdef HAVE_OMALLOC
155  static const omBin InternalPoly_bin;
156  void* operator new(size_t)
157  {
158  void* addr;
159  omTypeAllocBin(void*, addr, InternalPoly_bin);
160  return addr;
161  }
162  void operator delete(void* addr, size_t)
163  {
164  omFreeBin(addr, InternalPoly_bin);
165  }
166 #endif
167  friend class CFIterator;
168 };
169 
170 #endif /* ! INCL_INT_POLY_H */
term * termList
Definition: int_poly.h:60
omBin_t * omBin
Definition: omStructs.h:12
Definition: int_poly.h:33
bool inCoeffDomain() const
Definition: int_poly.h:111
factory&#39;s class for variables
Definition: factory.h:115
int exp
Definition: int_poly.h:37
bool inQuotDomain() const
Definition: int_poly.h:113
static poly last
Definition: hdegree.cc:1077
Variable variable() const
Definition: int_poly.h:98
factory&#39;s main class
Definition: canonicalform.h:75
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203
CanonicalForm Lc(const CanonicalForm &f)
void tryInvert(const CanonicalForm &F, const CanonicalForm &M, CanonicalForm &inv, bool &fail)
Definition: cfGcdAlgExt.cc:219
static const omBin InternalPoly_bin
Definition: int_poly.h:155
virtual class for internal CanonicalForm&#39;s
Definition: int_cf.h:39
CanonicalForm lc(const CanonicalForm &f)
CanonicalForm coeff
Definition: int_poly.h:36
term * next
Definition: int_poly.h:35
termList lastTerm
Definition: int_poly.h:73
int taildegree(const CanonicalForm &f)
Variable var
Definition: int_poly.h:74
int level() const
Definition: factory.h:132
term()
Definition: int_poly.h:42
factory&#39;s class for polynomials
Definition: int_poly.h:71
int i
Definition: cfEzgcd.cc:123
factory switches.
class to iterate through CanonicalForm&#39;s
Definition: cf_iter.h:44
static const omBin term_bin
Definition: int_poly.h:39
operations on variables
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
bool inExtension() const
Definition: int_poly.h:110
const char * classname() const
Definition: int_poly.h:96
CanonicalForm tailcoeff(const CanonicalForm &f)
term(term *n, const CanonicalForm &c, int e)
Definition: int_poly.h:43
#define OSTREAM
Definition: int_poly.h:17
Factory&#39;s internal CanonicalForm&#39;s.
bool inPolyDomain() const
Definition: int_poly.h:112
int level() const
Definition: int_poly.h:97
int degree(const CanonicalForm &f)
CanonicalForm LC(const CanonicalForm &f)
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
bool inBaseDomain() const
Definition: int_poly.h:109
friend class InternalPoly
Definition: int_poly.h:44
static int sign(int x)
Definition: ring.cc:3412
Header for factory&#39;s main class CanonicalForm.