source: git/factory/int_poly.h @ f78374

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