source: git/factory/int_poly.h @ 341696

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