source: git/factory/int_poly.h @ f79b94c

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