source: git/factory/int_poly.h @ ab547e2

spielwiese
Last change on this file since ab547e2 was ab58510, checked in by Hans Schoenemann <hannes@…>, 13 years ago
more singular stuff removed git-svn-id: file:///usr/local/Singular/svn/trunk@13624 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.5 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 size)
44    {
45      void* addr;
46      omTypeAllocBin(void*, addr, term_bin);
47      return addr;
48    }
49  void operator delete(void* addr, size_t size)
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 modTermList ( termList, const CanonicalForm&, termList& );
74    static void appendTermList ( termList&, termList&, const CanonicalForm&, const int );
75    static termList mulAddTermList ( termList theList, termList aList, const CanonicalForm & c, const int exp, termList & lastTerm, bool negate );
76    static termList reduceTermList ( termList first, termList redterms, termList & last );
77public:
78    InternalPoly();
79    InternalPoly( const Variable & v, const int e, const CanonicalForm& c );
80    InternalPoly( const InternalPoly& );
81    ~InternalPoly();
82    InternalCF* deepCopyObject() const;
83    const char * const classname() const { return "InternalPoly"; }
84    int level() const { return var.level(); }
85    Variable variable() const { return var; }
86    int degree();
87    CanonicalForm lc();
88    CanonicalForm Lc();
89    CanonicalForm LC();
90    int taildegree();
91    CanonicalForm tailcoeff();
92    CanonicalForm coeff( int i );
93#ifndef NOSTREAMIO
94    void print( OSTREAM&, char* );
95#endif /* NOSTREAMIO */
96    bool inBaseDomain() const { return false; }
97    bool inExtension() const { return var.level() < 0; }
98    bool inCoeffDomain() const { return var.level() < 0; }
99    bool inPolyDomain() const { return var.level() > 0; }
100    bool inQuotDomain() const { return false; }
101    InternalCF* genZero();
102    InternalCF* genOne();
103
104    bool isUnivariate() const;
105
106    InternalCF* neg();
107    InternalCF* invert();
108
109    int comparesame ( InternalCF* );
110
111    InternalCF* addsame( InternalCF* );
112    InternalCF* subsame( InternalCF* );
113    InternalCF* mulsame( InternalCF* );
114    InternalCF* dividesame( InternalCF* );
115    InternalCF* modulosame( InternalCF* );
116    InternalCF* divsame( InternalCF* );
117    InternalCF* modsame( InternalCF* );
118    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
119    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
120
121    int comparecoeff ( InternalCF* );
122
123    InternalCF* addcoeff( InternalCF* );
124    InternalCF* subcoeff( InternalCF*, bool );
125    InternalCF* mulcoeff( InternalCF* );
126    InternalCF* dividecoeff( InternalCF*, bool );
127    InternalCF* modulocoeff( InternalCF*, bool );
128    InternalCF* divcoeff( InternalCF*, bool );
129    InternalCF* modcoeff( InternalCF*, bool );
130    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
131    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
132
133    int sign() const;
134
135#ifdef HAVE_OMALLOC
136  static const omBin InternalPoly_bin;
137  void* operator new(size_t size)
138    {
139      void* addr;
140      omTypeAllocBin(void*, addr, InternalPoly_bin);
141      return addr;
142    }
143  void operator delete(void* addr, size_t size)
144    {
145      omFreeBin(addr, InternalPoly_bin);
146    }
147#endif
148    friend class CFIterator;
149};
150
151#endif /* ! INCL_INT_POLY_H */
Note: See TracBrowser for help on using the repository browser.