My Project  debian-1:4.1.1-p2+ds-4build4
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:
76 
77  static termList copyTermList ( termList, termList&, bool negate = false );
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 );
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 
116  { return firstTerm->coeff.genZero().getval(); }
117 
119  { return firstTerm->coeff.genOne().getval(); }
120 
121  bool isUnivariate() const;
122 
123  InternalCF* neg();
124  InternalCF* invert();
125  InternalCF* tryInvert( const CanonicalForm&, bool& );
126  int comparesame ( InternalCF* );
127 
135  InternalCF* tryDivsame ( InternalCF*, const CanonicalForm&, bool& );
139  bool tryDivremsamet( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
140 
141  int comparecoeff ( InternalCF* );
142 
144  InternalCF* subcoeff( InternalCF*, bool );
146  InternalCF* dividecoeff( InternalCF*, bool );
147  InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
148  InternalCF* modulocoeff( InternalCF*, bool );
149  InternalCF* divcoeff( InternalCF*, bool );
150  InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
151  InternalCF* modcoeff( InternalCF*, bool );
152  void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
153  bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
154  bool tryDivremcoefft ( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
155 
156  int sign() const;
157 
158 #ifdef HAVE_OMALLOC
159  static const omBin InternalPoly_bin;
160  void* operator new(size_t)
161  {
162  void* addr;
163  omTypeAllocBin(void*, addr, InternalPoly_bin);
164  return addr;
165  }
166  void operator delete(void* addr, size_t)
167  {
169  }
170 #endif
171  friend class CFIterator;
172 };
173 
174 #endif /* ! INCL_INT_POLY_H */
Header for factory's main class CanonicalForm.
int i
Definition: cfEzgcd.cc:125
factory switches.
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
factory's main class
Definition: canonicalform.h:83
CanonicalForm genOne() const
InternalCF * getval() const
CanonicalForm genZero() const
genOne(), genZero()
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
factory's class for polynomials
Definition: int_poly.h:71
InternalCF * addsame(InternalCF *)
Definition: int_poly.cc:278
static termList divideTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2007
int taildegree()
Definition: int_poly.cc:145
static termList addTermList(termList, termList, termList &, bool negate)
Definition: int_poly.cc:1914
InternalCF * mulcoeff(InternalCF *)
Definition: int_poly.cc:1173
Variable var
Definition: int_poly.h:74
void print(OSTREAM &, char *)
Definition: int_poly.cc:171
static termList reduceTermList(termList first, termList redterms, termList &last)
Definition: int_poly.cc:2224
CanonicalForm LC()
Definition: int_poly.cc:130
InternalCF * modsame(InternalCF *)
Definition: int_poly.cc:685
int degree()
int InternalPoly::degree ()
Definition: int_poly.cc:92
static void freeTermList(termList)
Definition: int_poly.cc:1890
InternalCF * deepCopyObject() const
Definition: int_poly.cc:68
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:809
InternalCF * neg()
InternalCF * InternalPoly::neg ()
Definition: int_poly.cc:223
InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1467
static const omBin InternalPoly_bin
Definition: int_poly.h:159
static void mulTermList(termList, const CanonicalForm &, const int)
Definition: int_poly.cc:1996
bool inQuotDomain() const
Definition: int_poly.h:113
bool isUnivariate() const
Definition: int_poly.cc:76
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1644
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalPoly.
Definition: int_poly.cc:982
bool inBaseDomain() const
Definition: int_poly.h:109
InternalCF * invert()
Definition: int_poly.cc:239
InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1295
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_poly.cc:1566
Variable variable() const
Definition: int_poly.h:98
InternalCF * subsame(InternalCF *)
Definition: int_poly.cc:318
termList firstTerm
Definition: int_poly.h:73
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_poly.cc:1391
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_poly.cc:1580
bool inCoeffDomain() const
Definition: int_poly.h:111
bool inExtension() const
Definition: int_poly.h:110
InternalCF * modulosame(InternalCF *)
Definition: int_poly.cc:679
static void negateTermList(termList)
Definition: int_poly.cc:1903
static termList tryDivTermList(termList, const CanonicalForm &, termList &, const CanonicalForm &, bool &)
Definition: int_poly.cc:2065
static termList mulAddTermList(termList theList, termList aList, const CanonicalForm &c, const int exp, termList &lastTerm, bool negate)
Definition: int_poly.cc:2140
bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1747
int level() const
Definition: int_poly.h:97
termList lastTerm
Definition: int_poly.h:73
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:757
InternalCF * dividesame(InternalCF *)
Definition: int_poly.cc:483
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1681
CanonicalForm coeff(int i)
CanonicalForm InternalPoly::coeff ( int i )
Definition: int_poly.cc:154
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_poly.cc:1209
int comparecoeff(InternalCF *)
comparecoeff() always returns 1 since CO is defined to be larger than anything which is a coefficient...
Definition: int_poly.cc:1024
CanonicalForm tailcoeff()
CanonicalForm InternalPoly::tailcoeff (), int InternalPoly::taildegree ()
Definition: int_poly.cc:139
static termList deepCopyTermList(termList, termList &)
Definition: int_poly.cc:1865
InternalCF * divsame(InternalCF *)
Definition: int_poly.cc:490
InternalCF * addcoeff(InternalCF *)
Definition: int_poly.cc:1030
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_poly.cc:1087
bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_poly.cc:875
InternalCF * genZero()
Definition: int_poly.h:115
CanonicalForm lc()
Definition: int_poly.cc:112
static termList modTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2096
static termList copyTermList(termList, termList &, bool negate=false)
Definition: int_poly.cc:1822
static void appendTermList(termList &, termList &, const CanonicalForm &, const int)
Definition: int_poly.cc:2125
CanonicalForm Lc()
Definition: int_poly.cc:121
static termList divTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2036
InternalCF * mulsame(InternalCF *)
Definition: int_poly.cc:358
InternalCF * tryInvert(const CanonicalForm &, bool &)
Definition: int_poly.cc:256
InternalCF * genOne()
Definition: int_poly.h:118
InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
Definition: int_poly.cc:420
int sign() const
int InternalPoly::sign () const
Definition: int_poly.cc:102
InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_poly.cc:576
bool inPolyDomain() const
Definition: int_poly.h:112
const char * classname() const
Definition: int_poly.h:96
factory's class for variables
Definition: factory.h:118
int level() const
Definition: factory.h:134
Definition: int_poly.h:33
term(term *n, const CanonicalForm &c, int e)
Definition: int_poly.h:43
static const omBin term_bin
Definition: int_poly.h:39
term * next
Definition: int_poly.h:35
CanonicalForm coeff
Definition: int_poly.h:36
term()
Definition: int_poly.h:42
int exp
Definition: int_poly.h:37
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static poly last
Definition: hdegree.cc:1077
Factory's internal CanonicalForm's.
#define OSTREAM
Definition: int_poly.h:17
term * termList
Definition: int_poly.h:60
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
omBin_t * omBin
Definition: omStructs.h:12
operations on variables