source: git/factory/canonicalform.h @ 71da5e

spielwiese
Last change on this file since 71da5e was 71da5e, checked in by Jens Schmidt <schmidt@…>, 26 years ago
* ftmpl_array.h, ftmpl_factor.h, ftmpl_functions.h, ftmpl_list.h, ftmpl_matrix.h: new files. #include of `templates/ftmpl_xxx.h' changed to include of `ftmpl_xxx.h'. git-svn-id: file:///usr/local/Singular/svn/trunk@1203 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.6 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: canonicalform.h,v 1.23 1998-03-10 14:47:58 schmidt Exp $ */
3
4#ifndef INCL_CANONICALFORM_H
5#define INCL_CANONICALFORM_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 "variable.h"
15#include "ftmpl_list.h"
16#include "ftmpl_array.h"
17#include "ftmpl_factor.h"
18#include "ftmpl_matrix.h"
19
20/*BEGINPUBLIC*/
21
22int initCanonicalForm( void );
23
24static int cf_is_initialized_now = initCanonicalForm();
25
26class InternalCF;
27
28//{{{ class CanonicalForm
29class CanonicalForm
30{
31private:
32    InternalCF *value;
33public:
34    // constructors, destructors, selectors
35    CanonicalForm();
36    CanonicalForm( const CanonicalForm& );
37    CanonicalForm( InternalCF* );
38    CanonicalForm( const int );
39    CanonicalForm( const Variable & );
40    CanonicalForm( const Variable &, int );
41    CanonicalForm( const char * ); // use with caution - does only handle integers !!!
42
43    ~CanonicalForm();
44
45    InternalCF* getval() const; // use with caution !!!
46
47    CanonicalForm deepCopy() const;
48
49    // predicates
50    bool isOne() const;
51    bool isZero() const;
52    bool isImm() const;
53
54    bool inZ() const;
55    bool inQ() const;
56    bool inFF() const;
57    bool inGF() const;
58    bool inPP() const;
59    bool inBaseDomain() const;
60    bool inExtension() const;
61    bool inCoeffDomain() const;
62    bool inPolyDomain() const;
63    bool inQuotDomain() const;
64
65    bool isFFinGF() const;
66    bool isUnivariate() const;
67
68    // conversion functions
69    int intval() const;
70    CanonicalForm mapinto () const;
71
72    CanonicalForm lc () const;
73    CanonicalForm Lc () const;
74    CanonicalForm LC () const;
75    CanonicalForm LC ( const Variable & v ) const;
76
77    int degree () const;
78    int degree ( const Variable & v ) const;
79
80    CanonicalForm tailcoeff () const;
81    int taildegree () const;
82
83    int level () const;
84    Variable mvar () const;
85
86    CanonicalForm num () const;
87    CanonicalForm den () const;
88
89    // assignment operators
90    CanonicalForm& operator = ( const CanonicalForm& );
91    CanonicalForm& operator = ( const int );
92
93    CanonicalForm& operator += ( const CanonicalForm& );
94    CanonicalForm& operator -= ( const CanonicalForm& );
95    CanonicalForm& operator *= ( const CanonicalForm& );
96    CanonicalForm& operator /= ( const CanonicalForm& );
97    CanonicalForm& operator %= ( const CanonicalForm& );
98    CanonicalForm& div ( const CanonicalForm& );
99    CanonicalForm& mod ( const CanonicalForm& );
100
101    // evaluation operators
102    CanonicalForm operator () ( const CanonicalForm & f ) const;
103    CanonicalForm operator () ( const CanonicalForm & f, const Variable & v ) const;
104
105    CanonicalForm operator [] ( int i ) const;
106
107    CanonicalForm deriv() const;
108    CanonicalForm deriv( const Variable & x ) const;
109
110    int sign() const;
111    CanonicalForm sqrt() const;
112    int ilog2() const;
113
114    // comparison operators
115    friend bool operator == ( const CanonicalForm&, const CanonicalForm& );
116    friend bool operator != ( const CanonicalForm&, const CanonicalForm& );
117    friend bool operator > ( const CanonicalForm&, const CanonicalForm& );
118    friend bool operator < ( const CanonicalForm&, const CanonicalForm& );
119
120    // arithmetic operators
121    friend CanonicalForm operator - ( const CanonicalForm& );
122
123    friend CanonicalForm operator + ( const CanonicalForm&, const CanonicalForm& );
124    friend CanonicalForm operator - ( const CanonicalForm&, const CanonicalForm& );
125    friend CanonicalForm operator * ( const CanonicalForm&, const CanonicalForm& );
126    friend CanonicalForm operator / ( const CanonicalForm&, const CanonicalForm& );
127    friend CanonicalForm operator % ( const CanonicalForm&, const CanonicalForm& );
128
129    friend CanonicalForm div ( const CanonicalForm&, const CanonicalForm& );
130    friend CanonicalForm mod ( const CanonicalForm&, const CanonicalForm& );
131
132    friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
133    friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
134
135    friend CanonicalForm bgcd ( const CanonicalForm &, const CanonicalForm & );
136    friend CanonicalForm bextgcd ( const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm & );
137
138    // input/output
139#ifndef NOSTREAMIO
140    void print( ostream&, char * ) const;
141    friend ostream& operator << ( ostream&, const CanonicalForm& );
142    friend istream& operator >> ( istream&, CanonicalForm& );
143#endif /* NOSTREAMIO */
144
145    // obsolete methods
146    static CanonicalForm genCoeff( int what, int i = 0 );
147    CanonicalForm genZero() const;
148    CanonicalForm genOne() const;
149
150    friend class CFIterator;
151};
152//}}}
153
154//{{{ function declarations from canonicalform.cc
155CanonicalForm power ( const CanonicalForm & f, int n );
156
157CanonicalForm power ( const Variable & v, int n );
158//}}}
159
160//{{{ function declarations from cf_gcd.cc
161CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
162
163CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
164
165CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
166
167CanonicalForm pp ( const CanonicalForm& );
168
169CanonicalForm content ( const CanonicalForm& );
170
171CanonicalForm content ( const CanonicalForm&, const Variable& );
172
173CanonicalForm icontent ( const CanonicalForm & f );
174//}}}
175
176//{{{ function declarations from cf_ops.cc
177CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & );
178
179CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & );
180
181int getNumVars( const CanonicalForm & f );
182
183CanonicalForm getVars( const CanonicalForm & f );
184
185CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
186
187CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
188
189int * degrees ( const CanonicalForm & f, int * degs = 0 );
190
191int totaldegree ( const CanonicalForm & f );
192
193int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
194
195int size ( const CanonicalForm & f, const Variable & v );
196
197int size ( const CanonicalForm & f );
198//}}}
199
200//{{{ inline functions corresponding to CanonicalForm methods
201//{{{ docu
202//
203// - inline functions corresponding to CanonicalForm methods.
204//
205// These function exist for convenience only and because it is
206// more beautiful to write 'degree( f )' than 'f.degree()'.
207//
208//}}}
209inline CanonicalForm
210lc ( const CanonicalForm & f ) { return f.lc(); }
211
212inline CanonicalForm
213Lc ( const CanonicalForm & f ) { return f.Lc(); }
214
215inline CanonicalForm
216LC ( const CanonicalForm & f ) { return f.LC(); }
217
218inline CanonicalForm
219LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
220
221inline int
222degree ( const CanonicalForm & f ) { return f.degree(); }
223
224inline int
225degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
226
227inline int
228taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
229
230inline CanonicalForm
231tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
232
233inline int
234level ( const CanonicalForm & f ) { return f.level(); }
235
236inline Variable
237mvar ( const CanonicalForm & f ) { return f.mvar(); }
238
239inline CanonicalForm
240num ( const CanonicalForm & f ) { return f.num(); }
241
242inline CanonicalForm
243den ( const CanonicalForm & f ) { return f.den(); }
244
245inline CanonicalForm
246deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); }
247
248inline CanonicalForm
249sqrt ( const CanonicalForm & a ) { return a.sqrt(); }
250
251inline int
252ilog2 ( const CanonicalForm & a ) { return a.ilog2(); }
253
254inline CanonicalForm
255mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
256//}}}
257
258//{{{ inline functions
259inline CanonicalForm
260head ( const CanonicalForm & f )
261{
262    if ( f.level() > 0 )
263        return power( f.mvar(), f.degree() ) * f.LC();
264    else
265        return f;
266}
267
268inline CanonicalForm
269abs ( const CanonicalForm & f )
270{
271    if ( f < 0 )
272        return -f;
273    else
274        return f;
275}
276
277inline int
278headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
279//}}}
280
281//{{{ other function declarations
282void setCharacteristic( int c ); // -> Fp && Q
283void setCharacteristic( int c, int n ); // -> PrimePower
284void setCharacteristic( int c, int n, char name ); // -> GF(q)
285
286int getCharacteristic();
287int getGFDegree();
288CanonicalForm getGFGenerator();
289
290void On( int );
291void Off( int );
292bool isOn( int );
293//}}}
294
295//{{{ type definitions
296typedef Factor<CanonicalForm> CFFactor;
297typedef List<CFFactor> CFFList;
298typedef ListIterator<CFFactor> CFFListIterator;
299typedef List<CanonicalForm> CFList;
300typedef ListIterator<CanonicalForm> CFListIterator;
301typedef Array<CanonicalForm> CFArray;
302typedef Matrix<CanonicalForm> CFMatrix;
303//}}}
304
305/*ENDPUBLIC*/
306
307#endif /* ! INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.