source: git/factory/int_poly.h @ 8336c9

spielwiese
Last change on this file since 8336c9 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 5.1 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_INT_POLY_H
4#define INCL_INT_POLY_H
5
6// #include "config.h"
7
8#ifndef NOSTREAMIO
9#ifdef HAVE_IOSTREAM
10#include <iostream>
11#define OSTREAM std::ostream
12#elif defined(HAVE_IOSTREAM_H)
13#include <iostream.h>
14#define OSTREAM ostream
15#endif
16#endif /* NOSTREAMIO */
17
18#include "cf_defs.h"
19#include "int_cf.h"
20#include "variable.h"
21#include "canonicalform.h"
22
23#ifdef HAVE_OMALLOC
24#ifndef OM_NDEBUG
25#define OM_NDEBUG
26#endif
27#  include <omalloc/omalloc.h>
28#endif
29
30class term {
31private:
32    term * next;
33    CanonicalForm coeff;
34    int exp;
35#ifdef HAVE_OMALLOC
36  static const omBin term_bin;
37#endif
38public:
39    term() : next(0), coeff(0), exp(0) {}
40    term( term * n, const CanonicalForm & c, int e ) : next(n), coeff(c), exp(e) {}
41    friend class InternalPoly;
42    friend class CFIterator;
43#ifdef HAVE_OMALLOC
44  void* operator new(size_t)
45    {
46      void* addr;
47      omTypeAllocBin(void*, addr, term_bin);
48      return addr;
49    }
50  void operator delete(void* addr, size_t)
51    {
52      omFreeBin(addr, term_bin);
53    }
54#endif
55};
56
57typedef term * termList;
58
59
60class InternalPoly : public InternalCF {
61private:
62    termList firstTerm, lastTerm;
63    Variable var;
64    InternalPoly( termList, termList, const Variable & );
65
66    static termList copyTermList ( termList, termList&, bool negate = false );
67    static termList deepCopyTermList ( termList, termList& );
68    static void freeTermList ( termList );
69    static void negateTermList ( termList );
70    static termList addTermList ( termList, termList, termList&, bool negate );
71    static void mulTermList ( termList, const CanonicalForm& , const int );
72    static termList divideTermList ( termList, const CanonicalForm&, termList& );
73    static termList divTermList ( termList, const CanonicalForm&, termList& );
74    static termList tryDivTermList ( termList, const CanonicalForm&, termList&, const CanonicalForm&, bool& );
75    static termList modTermList ( termList, const CanonicalForm&, termList& );
76    static void appendTermList ( termList&, termList&, const CanonicalForm&, const int );
77    static termList mulAddTermList ( termList theList, termList aList, const CanonicalForm & c, const int exp, termList & lastTerm, bool negate );
78    static termList reduceTermList ( termList first, termList redterms, termList & last );
79public:
80    InternalPoly();
81    InternalPoly( const Variable & v, const int e, const CanonicalForm& c );
82    InternalPoly( const InternalPoly& );
83    ~InternalPoly();
84    InternalCF* deepCopyObject() const;
85    const char * classname() const { return "InternalPoly"; }
86    int level() const { return var.level(); }
87    Variable variable() const { return var; }
88    int degree();
89    CanonicalForm lc();
90    CanonicalForm Lc();
91    CanonicalForm LC();
92    int taildegree();
93    CanonicalForm tailcoeff();
94    CanonicalForm coeff( int i );
95#ifndef NOSTREAMIO
96    void print( OSTREAM&, char* );
97#endif /* NOSTREAMIO */
98    bool inBaseDomain() const { return false; }
99    bool inExtension() const { return var.level() < 0; }
100    bool inCoeffDomain() const { return var.level() < 0; }
101    bool inPolyDomain() const { return var.level() > 0; }
102    bool inQuotDomain() const { return false; }
103    InternalCF* genZero();
104    InternalCF* genOne();
105
106    bool isUnivariate() const;
107
108    InternalCF* neg();
109    InternalCF* invert();
110    InternalCF* tryInvert( const CanonicalForm&, bool& );
111    int comparesame ( InternalCF* );
112
113    InternalCF* addsame( InternalCF* );
114    InternalCF* subsame( InternalCF* );
115    InternalCF* mulsame( InternalCF* );
116    InternalCF* tryMulsame ( InternalCF*, const CanonicalForm&);
117    InternalCF* dividesame( InternalCF* );
118    InternalCF* modulosame( InternalCF* );
119    InternalCF* divsame( InternalCF* );
120    InternalCF* tryDivsame ( InternalCF*, const CanonicalForm&, bool& );
121    InternalCF* modsame( InternalCF* );
122    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
123    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
124    bool tryDivremsamet( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
125
126    int comparecoeff ( InternalCF* );
127
128    InternalCF* addcoeff( InternalCF* );
129    InternalCF* subcoeff( InternalCF*, bool );
130    InternalCF* mulcoeff( InternalCF* );
131    InternalCF* dividecoeff( InternalCF*, bool );
132    InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
133    InternalCF* modulocoeff( InternalCF*, bool );
134    InternalCF* divcoeff( InternalCF*, bool );
135    InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
136    InternalCF* modcoeff( InternalCF*, bool );
137    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
138    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
139    bool tryDivremcoefft ( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
140
141    int sign() const;
142
143#ifdef HAVE_OMALLOC
144  static const omBin InternalPoly_bin;
145  void* operator new(size_t)
146    {
147      void* addr;
148      omTypeAllocBin(void*, addr, InternalPoly_bin);
149      return addr;
150    }
151  void operator delete(void* addr, size_t)
152    {
153      omFreeBin(addr, InternalPoly_bin);
154    }
155#endif
156    friend class CFIterator;
157};
158
159#endif /* ! INCL_INT_POLY_H */
Note: See TracBrowser for help on using the repository browser.