source: git/factory/int_poly.h @ e16f7d

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