source: git/factory/canonicalform.h @ 6c5d86

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