My Project  UNKNOWN_GIT_VERSION
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 */
InternalPoly::inPolyDomain
bool inPolyDomain() const
Definition: int_poly.h:112
omalloc.h
InternalPoly::divremcoeff
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1652
InternalPoly::tryDivremsamet
bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_poly.cc:883
InternalPoly::inBaseDomain
bool inBaseDomain() const
Definition: int_poly.h:109
InternalPoly::divsame
InternalCF * divsame(InternalCF *)
Definition: int_poly.cc:498
InternalPoly::tailcoeff
CanonicalForm tailcoeff()
CanonicalForm InternalPoly::tailcoeff (), int InternalPoly::taildegree ()
Definition: int_poly.cc:147
InternalPoly::modulocoeff
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_poly.cc:1574
canonicalform.h
InternalPoly::level
int level() const
Definition: int_poly.h:97
CFIterator
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
InternalPoly::deepCopyObject
InternalCF * deepCopyObject() const
Definition: int_poly.cc:76
InternalPoly::firstTerm
termList firstTerm
Definition: int_poly.h:73
InternalPoly::subcoeff
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_poly.cc:1095
InternalPoly::tryDivremcoefft
bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1755
InternalPoly::mulcoeff
InternalCF * mulcoeff(InternalCF *)
Definition: int_poly.cc:1181
InternalPoly::isUnivariate
bool isUnivariate() const
Definition: int_poly.cc:84
InternalPoly::tryDividecoeff
InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1303
InternalPoly::neg
InternalCF * neg()
InternalCF * InternalPoly::neg ()
Definition: int_poly.cc:231
InternalPoly::invert
InternalCF * invert()
Definition: int_poly.cc:247
InternalPoly::comparesame
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalPoly.
Definition: int_poly.cc:990
InternalPoly::tryInvert
InternalCF * tryInvert(const CanonicalForm &, bool &)
Definition: int_poly.cc:264
InternalPoly::mulsame
InternalCF * mulsame(InternalCF *)
Definition: int_poly.cc:366
InternalPoly::coeff
CanonicalForm coeff(int i)
CanonicalForm InternalPoly::coeff ( int i )
Definition: int_poly.cc:162
term::coeff
CanonicalForm coeff
Definition: int_poly.h:36
InternalPoly::lastTerm
termList lastTerm
Definition: int_poly.h:73
InternalPoly::deepCopyTermList
static termList deepCopyTermList(termList, termList &)
Definition: int_poly.cc:1873
InternalCF
virtual class for internal CanonicalForm's
Definition: int_cf.h:41
InternalPoly::var
Variable var
Definition: int_poly.h:74
InternalPoly::modTermList
static termList modTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2104
termList
term * termList
Definition: int_poly.h:60
InternalPoly::inCoeffDomain
bool inCoeffDomain() const
Definition: int_poly.h:111
CanonicalForm
factory's main class
Definition: canonicalform.h:77
InternalPoly::appendTermList
static void appendTermList(termList &, termList &, const CanonicalForm &, const int)
Definition: int_poly.cc:2133
term
Definition: int_poly.h:33
InternalPoly::addTermList
static termList addTermList(termList, termList, termList &, bool negate)
Definition: int_poly.cc:1922
InternalPoly::inQuotDomain
bool inQuotDomain() const
Definition: int_poly.h:113
InternalPoly::variable
Variable variable() const
Definition: int_poly.h:98
term::term
term()
Definition: int_poly.h:42
InternalPoly::LC
CanonicalForm LC()
Definition: int_poly.cc:138
CanonicalForm::genOne
CanonicalForm genOne() const
Definition: canonicalform.cc:1822
i
int i
Definition: cfEzgcd.cc:125
InternalPoly::~InternalPoly
~InternalPoly()
Definition: int_poly.cc:70
term::exp
int exp
Definition: int_poly.h:37
InternalPoly::genZero
InternalCF * genZero()
Definition: int_poly.h:115
InternalPoly::genOne
InternalCF * genOne()
Definition: int_poly.h:118
InternalPoly::divideTermList
static termList divideTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2015
cf_defs.h
int_cf.h
term::next
term * next
Definition: int_poly.h:35
InternalPoly
factory's class for polynomials
Definition: int_poly.h:71
InternalPoly::mulAddTermList
static termList mulAddTermList(termList theList, termList aList, const CanonicalForm &c, const int exp, termList &lastTerm, bool negate)
Definition: int_poly.cc:2148
InternalPoly::divremsamet
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:817
InternalPoly::print
void print(OSTREAM &, char *)
Definition: int_poly.cc:179
InternalPoly::Lc
CanonicalForm Lc()
Definition: int_poly.cc:129
omTypeAllocBin
#define omTypeAllocBin(type, addr, bin)
Definition: omAllocDecl.h:203
InternalPoly::InternalPoly_bin
static const omBin InternalPoly_bin
Definition: int_poly.h:159
term::term
term(term *n, const CanonicalForm &c, int e)
Definition: int_poly.h:43
Variable::level
int level() const
Definition: factory.h:134
InternalPoly::degree
int degree()
int InternalPoly::degree ()
Definition: int_poly.cc:100
InternalPoly::dividesame
InternalCF * dividesame(InternalCF *)
Definition: int_poly.cc:491
InternalPoly::subsame
InternalCF * subsame(InternalCF *)
Definition: int_poly.cc:326
InternalPoly::addsame
InternalCF * addsame(InternalCF *)
Definition: int_poly.cc:286
InternalPoly::divTermList
static termList divTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2044
variable.h
last
static poly last
Definition: hdegree.cc:1077
OSTREAM
#define OSTREAM
Definition: int_poly.h:17
InternalPoly::classname
const char * classname() const
Definition: int_poly.h:96
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
InternalPoly::tryDivcoeff
InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1475
InternalPoly::reduceTermList
static termList reduceTermList(termList first, termList redterms, termList &last)
Definition: int_poly.cc:2232
omBin
omBin_t * omBin
Definition: omStructs.h:12
InternalPoly::divremcoefft
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1689
CanonicalForm::genZero
CanonicalForm genZero() const
genOne(), genZero()
Definition: canonicalform.cc:1808
InternalPoly::tryMulsame
InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
Definition: int_poly.cc:428
Variable
factory's class for variables
Definition: factory.h:117
InternalPoly::lc
CanonicalForm lc()
Definition: int_poly.cc:120
InternalPoly::divremsame
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:765
InternalPoly::modulosame
InternalCF * modulosame(InternalCF *)
Definition: int_poly.cc:687
InternalPoly::comparecoeff
int comparecoeff(InternalCF *)
comparecoeff() always returns 1 since CO is defined to be larger than anything which is a coefficient...
Definition: int_poly.cc:1032
InternalPoly::modsame
InternalCF * modsame(InternalCF *)
Definition: int_poly.cc:693
InternalPoly::freeTermList
static void freeTermList(termList)
Definition: int_poly.cc:1898
InternalPoly::addcoeff
InternalCF * addcoeff(InternalCF *)
Definition: int_poly.cc:1038
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
InternalPoly::tryDivTermList
static termList tryDivTermList(termList, const CanonicalForm &, termList &, const CanonicalForm &, bool &)
Definition: int_poly.cc:2073
InternalPoly::negateTermList
static void negateTermList(termList)
Definition: int_poly.cc:1911
InternalPoly::mulTermList
static void mulTermList(termList, const CanonicalForm &, const int)
Definition: int_poly.cc:2004
InternalPoly::modcoeff
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_poly.cc:1588
InternalPoly::taildegree
int taildegree()
Definition: int_poly.cc:153
InternalPoly::inExtension
bool inExtension() const
Definition: int_poly.h:110
InternalPoly::InternalPoly
InternalPoly()
Definition: int_poly.cc:53
term::term_bin
static const omBin term_bin
Definition: int_poly.h:39
InternalPoly::copyTermList
static termList copyTermList(termList, termList &, bool negate=false)
Definition: int_poly.cc:1830
omFreeBin
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
InternalPoly::divcoeff
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_poly.cc:1399
InternalPoly::dividecoeff
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_poly.cc:1217
InternalPoly::tryDivsame
InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_poly.cc:584
CanonicalForm::getval
InternalCF * getval() const
Definition: canonicalform.cc:31
InternalPoly::sign
int sign() const
int InternalPoly::sign () const
Definition: int_poly.cc:110