My Project
Loading...
Searching...
No Matches
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
33class term {
34private:
37 int exp;
38#ifdef HAVE_OMALLOC
39 static const omBin term_bin;
40#endif
41public:
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
60typedef 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**/
71class InternalPoly : public InternalCF {
72private:
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 );
85 static termList tryDivTermList ( termList, const CanonicalForm&, termList&, const CanonicalForm&, bool& );
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 );
90public:
92 InternalPoly( const Variable & v, const int e, const CanonicalForm& c );
93 InternalPoly( const InternalPoly& );
96 const char * classname() const { return "InternalPoly"; }
97 int level() const { return var.level(); }
98 Variable variable() const { return var; }
99 int degree();
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();
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 );
147 InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, 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
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:132
factory switches.
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
factory's main class
Definition: canonicalform.h:86
CanonicalForm genOne() const
InternalCF * getval() const
CanonicalForm genZero() const
input/output
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
factory's class for polynomials
Definition: int_poly.h:71
InternalCF * addsame(InternalCF *)
Definition: int_poly.cc:286
static termList divideTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2049
int taildegree()
Definition: int_poly.cc:153
static termList addTermList(termList, termList, termList &, bool negate)
Definition: int_poly.cc:1922
InternalCF * mulcoeff(InternalCF *)
Definition: int_poly.cc:1181
Variable var
Definition: int_poly.h:74
static termList reduceTermList(termList first, termList redterms, termList &last)
Definition: int_poly.cc:2266
CanonicalForm LC()
Definition: int_poly.cc:138
InternalCF * modsame(InternalCF *)
Definition: int_poly.cc:693
int degree()
int InternalPoly::degree ()
Definition: int_poly.cc:100
static void freeTermList(termList)
Definition: int_poly.cc:1898
InternalCF * deepCopyObject() const
Definition: int_poly.cc:76
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:817
InternalCF * neg()
InternalCF * InternalPoly::neg ()
Definition: int_poly.cc:231
InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1475
static const omBin InternalPoly_bin
Definition: int_poly.h:159
static void mulTermList(termList, const CanonicalForm &, const int)
Definition: int_poly.cc:2038
bool inQuotDomain() const
Definition: int_poly.h:113
bool isUnivariate() const
Definition: int_poly.cc:84
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1652
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalPoly.
Definition: int_poly.cc:990
bool inBaseDomain() const
Definition: int_poly.h:109
InternalCF * genZero()
Definition: int_poly.h:115
InternalCF * invert()
Definition: int_poly.cc:247
InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1303
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_poly.cc:1574
Variable variable() const
Definition: int_poly.h:98
InternalCF * subsame(InternalCF *)
Definition: int_poly.cc:326
termList firstTerm
Definition: int_poly.h:73
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_poly.cc:1399
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_poly.cc:1588
bool inCoeffDomain() const
Definition: int_poly.h:111
bool inExtension() const
Definition: int_poly.h:110
InternalCF * modulosame(InternalCF *)
Definition: int_poly.cc:687
static void negateTermList(termList)
Definition: int_poly.cc:1911
static termList tryDivTermList(termList, const CanonicalForm &, termList &, const CanonicalForm &, bool &)
Definition: int_poly.cc:2107
static termList mulAddTermList(termList theList, termList aList, const CanonicalForm &c, const int exp, termList &lastTerm, bool negate)
Definition: int_poly.cc:2182
bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
Definition: int_poly.cc:1755
int level() const
Definition: int_poly.h:97
termList lastTerm
Definition: int_poly.h:73
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_poly.cc:765
InternalCF * dividesame(InternalCF *)
Definition: int_poly.cc:491
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_poly.cc:1689
CanonicalForm coeff(int i)
CanonicalForm InternalPoly::coeff ( int i )
Definition: int_poly.cc:162
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_poly.cc:1217
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
CanonicalForm tailcoeff()
CanonicalForm InternalPoly::tailcoeff (), int InternalPoly::taildegree ()
Definition: int_poly.cc:147
static termList deepCopyTermList(termList, termList &)
Definition: int_poly.cc:1873
InternalCF * divsame(InternalCF *)
Definition: int_poly.cc:498
InternalCF * addcoeff(InternalCF *)
Definition: int_poly.cc:1038
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_poly.cc:1095
const char * classname() const
Definition: int_poly.h:96
bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
Definition: int_poly.cc:883
CanonicalForm lc()
Definition: int_poly.cc:120
static termList modTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2138
static termList copyTermList(termList, termList &, bool negate=false)
Definition: int_poly.cc:1830
InternalCF * genOne()
Definition: int_poly.h:118
static void appendTermList(termList &, termList &, const CanonicalForm &, const int)
Definition: int_poly.cc:2167
CanonicalForm Lc()
Definition: int_poly.cc:129
static termList divTermList(termList, const CanonicalForm &, termList &)
Definition: int_poly.cc:2078
InternalCF * mulsame(InternalCF *)
Definition: int_poly.cc:366
InternalCF * tryInvert(const CanonicalForm &, bool &)
Definition: int_poly.cc:264
InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
Definition: int_poly.cc:428
int sign() const
int InternalPoly::sign () const
Definition: int_poly.cc:110
InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
Definition: int_poly.cc:584
bool inPolyDomain() const
Definition: int_poly.h:112
factory's class for variables
Definition: variable.h:33
int level() const
Definition: variable.h:49
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:39
STATIC_VAR poly last
Definition: hdegree.cc:1173
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:357
#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