1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: int_poly.h,v 1.2 1997-04-15 09:14:20 schmidt Exp $ |
---|
3 | |
---|
4 | #ifndef INCL_INTERNALPOLY_H |
---|
5 | #define INCL_INTERNALPOLY_H |
---|
6 | |
---|
7 | /* |
---|
8 | $Log: not supported by cvs2svn $ |
---|
9 | Revision 1.1 1997/03/27 10:08:06 schmidt |
---|
10 | stream-io wrapped by NOSTREAMIO |
---|
11 | |
---|
12 | Revision 1.0 1996/05/17 10:59:41 stobbe |
---|
13 | Initial revision |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | #include <config.h> |
---|
18 | |
---|
19 | #ifndef NOSTREAMIO |
---|
20 | #include <iostream.h> |
---|
21 | #endif /* NOSTREAMIO */ |
---|
22 | |
---|
23 | #include "cf_defs.h" |
---|
24 | #include "int_cf.h" |
---|
25 | #include "variable.h" |
---|
26 | #include "canonicalform.h" |
---|
27 | |
---|
28 | |
---|
29 | class term { |
---|
30 | private: |
---|
31 | term * next; |
---|
32 | CanonicalForm coeff; |
---|
33 | int exp; |
---|
34 | public: |
---|
35 | term() : next(0), coeff(0), exp(0) {} |
---|
36 | term( term * n, const CanonicalForm & c, int e ) : next(n), coeff(c), exp(e) {} |
---|
37 | friend class InternalPoly; |
---|
38 | friend class CFIterator; |
---|
39 | }; |
---|
40 | |
---|
41 | typedef term * termList; |
---|
42 | |
---|
43 | |
---|
44 | class InternalPoly : public InternalCF { |
---|
45 | private: |
---|
46 | termList firstTerm, lastTerm; |
---|
47 | Variable var; |
---|
48 | InternalPoly( termList, termList, const Variable & ); |
---|
49 | |
---|
50 | static termList copyTermList ( termList, termList&, bool negate = false ); |
---|
51 | static termList deepCopyTermList ( termList, termList& ); |
---|
52 | static void freeTermList ( termList ); |
---|
53 | static void negateTermList ( termList ); |
---|
54 | static termList addTermList ( termList, termList, termList&, bool negate ); |
---|
55 | static void mulTermList ( termList, const CanonicalForm& , const int ); |
---|
56 | static termList divTermList ( termList, const CanonicalForm&, termList& ); |
---|
57 | static termList modTermList ( termList, const CanonicalForm&, termList& ); |
---|
58 | static void appendTermList ( termList&, termList&, const CanonicalForm&, const int ); |
---|
59 | static termList mulAddTermList ( termList theList, termList aList, const CanonicalForm & c, const int exp, termList & lastTerm, bool negate ); |
---|
60 | static termList reduceTermList ( termList first, termList redterms, termList & last ); |
---|
61 | public: |
---|
62 | InternalPoly(); |
---|
63 | InternalPoly( const Variable & v, const int e, const CanonicalForm& c ); |
---|
64 | InternalPoly( const InternalPoly& ); |
---|
65 | ~InternalPoly(); |
---|
66 | InternalCF* deepCopyObject() const; |
---|
67 | const char * const classname() const { return "InternalPoly"; } |
---|
68 | int level() const { return var.level(); } |
---|
69 | Variable variable() const { return var; } |
---|
70 | int degree(); |
---|
71 | CanonicalForm lc(); |
---|
72 | CanonicalForm LC(); |
---|
73 | int taildegree(); |
---|
74 | CanonicalForm tailcoeff(); |
---|
75 | CanonicalForm coeff( int i ); |
---|
76 | #ifndef NOSTREAMIO |
---|
77 | void print( ostream&, char* ); |
---|
78 | #endif /* NOSTREAMIO */ |
---|
79 | bool isZero() const { return false; } |
---|
80 | bool isOne() const { return false; } |
---|
81 | bool inBaseDomain() const { return false; } |
---|
82 | bool inExtension() const { return var.level() < 0; } |
---|
83 | bool inCoeffDomain() const { return var.level() < 0; } |
---|
84 | bool inPolyDomain() const { return var.level() > 0; } |
---|
85 | bool inQuotDomain() const { return false; } |
---|
86 | InternalCF* genZero(); |
---|
87 | InternalCF* genOne(); |
---|
88 | |
---|
89 | bool isUnivariate() const; |
---|
90 | |
---|
91 | InternalCF* neg(); |
---|
92 | InternalCF* invert(); |
---|
93 | |
---|
94 | int comparesame ( InternalCF* ); |
---|
95 | |
---|
96 | InternalCF* addsame( InternalCF* ); |
---|
97 | InternalCF* subsame( InternalCF* ); |
---|
98 | InternalCF* mulsame( InternalCF* ); |
---|
99 | InternalCF* dividesame( InternalCF* ); |
---|
100 | InternalCF* modulosame( InternalCF* ); |
---|
101 | InternalCF* divsame( InternalCF* ); |
---|
102 | InternalCF* modsame( InternalCF* ); |
---|
103 | void divremsame( InternalCF*, InternalCF*&, InternalCF*& ); |
---|
104 | bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& ); |
---|
105 | |
---|
106 | int comparecoeff ( InternalCF* ); |
---|
107 | |
---|
108 | InternalCF* addcoeff( InternalCF* ); |
---|
109 | InternalCF* subcoeff( InternalCF*, bool ); |
---|
110 | InternalCF* mulcoeff( InternalCF* ); |
---|
111 | InternalCF* dividecoeff( InternalCF*, bool ); |
---|
112 | InternalCF* modulocoeff( InternalCF*, bool ); |
---|
113 | InternalCF* divcoeff( InternalCF*, bool ); |
---|
114 | InternalCF* modcoeff( InternalCF*, bool ); |
---|
115 | void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool ); |
---|
116 | bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool ); |
---|
117 | |
---|
118 | int sign() const; |
---|
119 | |
---|
120 | friend class CFIterator; |
---|
121 | }; |
---|
122 | |
---|
123 | |
---|
124 | #endif /* INCL_INTERNALPOLY_H */ |
---|