source: git/factory/int_poly.h @ 362fc67

jengelh-datetimespielwiese
Last change on this file since 362fc67 was 362fc67, checked in by Martin Lee <martinlee84@…>, 11 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 5.1 KB
RevLine 
[493c477]1/* emacs edit mode for this file is -*- C++ -*- */
[2dd068]2
[493c477]3#ifndef INCL_INT_POLY_H
4#define INCL_INT_POLY_H
[2dd068]5
[e4fe2b]6// #include "config.h"
[9d7aaa]7
[718e670]8#ifndef NOSTREAMIO
[1dc616]9#ifdef HAVE_IOSTREAM
10#include <iostream>
[181148]11#define OSTREAM std::ostream
[1dc616]12#elif defined(HAVE_IOSTREAM_H)
[718e670]13#include <iostream.h>
[181148]14#define OSTREAM ostream
[1dc616]15#endif
[718e670]16#endif /* NOSTREAMIO */
17
[2dd068]18#include "cf_defs.h"
19#include "int_cf.h"
20#include "variable.h"
21#include "canonicalform.h"
22
[f79b94c]23#ifdef HAVE_OMALLOC
[1a9dc5]24#ifndef OM_NDEBUG
[ab58510]25#define OM_NDEBUG
[1a9dc5]26#endif
[b1dfaf]27#  include <omalloc/omalloc.h>
[f79b94c]28#endif
[2dd068]29
30class term {
31private:
32    term * next;
33    CanonicalForm coeff;
34    int exp;
[f79b94c]35#ifdef HAVE_OMALLOC
36  static const omBin term_bin;
37#endif
[2dd068]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;
[f79b94c]43#ifdef HAVE_OMALLOC
[0349c20]44  void* operator new(size_t)
[f79b94c]45    {
46      void* addr;
47      omTypeAllocBin(void*, addr, term_bin);
48      return addr;
49    }
[0349c20]50  void operator delete(void* addr, size_t)
[f79b94c]51    {
52      omFreeBin(addr, term_bin);
53    }
54#endif
[2dd068]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 );
[fc732a9]72    static termList divideTermList ( termList, const CanonicalForm&, termList& );
[2dd068]73    static termList divTermList ( termList, const CanonicalForm&, termList& );
[ec970e]74    static termList tryDivTermList ( termList, const CanonicalForm&, termList&, const CanonicalForm&, bool& );
[2dd068]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;
[c770dc]85    const char * classname() const { return "InternalPoly"; }
[2dd068]86    int level() const { return var.level(); }
87    Variable variable() const { return var; }
88    int degree();
89    CanonicalForm lc();
[791c0a]90    CanonicalForm Lc();
[2dd068]91    CanonicalForm LC();
92    int taildegree();
93    CanonicalForm tailcoeff();
94    CanonicalForm coeff( int i );
[718e670]95#ifndef NOSTREAMIO
[181148]96    void print( OSTREAM&, char* );
[718e670]97#endif /* NOSTREAMIO */
[2dd068]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();
[ec970e]110    InternalCF* tryInvert( const CanonicalForm&, bool& );
[2dd068]111    int comparesame ( InternalCF* );
112
113    InternalCF* addsame( InternalCF* );
114    InternalCF* subsame( InternalCF* );
[718e670]115    InternalCF* mulsame( InternalCF* );
[ec970e]116    InternalCF* tryMulsame ( InternalCF*, const CanonicalForm&);
[2dd068]117    InternalCF* dividesame( InternalCF* );
118    InternalCF* modulosame( InternalCF* );
119    InternalCF* divsame( InternalCF* );
[ec970e]120    InternalCF* tryDivsame ( InternalCF*, const CanonicalForm&, bool& );
[2dd068]121    InternalCF* modsame( InternalCF* );
122    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
123    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
[ec970e]124    bool tryDivremsamet( InternalCF*, InternalCF*&, InternalCF*&, const CanonicalForm&, bool& );
[2dd068]125
126    int comparecoeff ( InternalCF* );
127
128    InternalCF* addcoeff( InternalCF* );
129    InternalCF* subcoeff( InternalCF*, bool );
[718e670]130    InternalCF* mulcoeff( InternalCF* );
131    InternalCF* dividecoeff( InternalCF*, bool );
[ec970e]132    InternalCF* tryDividecoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
[718e670]133    InternalCF* modulocoeff( InternalCF*, bool );
134    InternalCF* divcoeff( InternalCF*, bool );
[ec970e]135    InternalCF* tryDivcoeff ( InternalCF*, bool, const CanonicalForm&, bool& );
[2dd068]136    InternalCF* modcoeff( InternalCF*, bool );
137    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
138    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
[ec970e]139    bool tryDivremcoefft ( InternalCF*, InternalCF*&, InternalCF*&, bool, const CanonicalForm&, bool& );
[2dd068]140
141    int sign() const;
142
[f79b94c]143#ifdef HAVE_OMALLOC
144  static const omBin InternalPoly_bin;
[0349c20]145  void* operator new(size_t)
[f79b94c]146    {
147      void* addr;
148      omTypeAllocBin(void*, addr, InternalPoly_bin);
149      return addr;
150    }
[0349c20]151  void operator delete(void* addr, size_t)
[f79b94c]152    {
153      omFreeBin(addr, InternalPoly_bin);
154    }
155#endif
[2dd068]156    friend class CFIterator;
157};
158
[493c477]159#endif /* ! INCL_INT_POLY_H */
Note: See TracBrowser for help on using the repository browser.