source: git/factory/canonicalform.h @ 518a1f

spielwiese
Last change on this file since 518a1f was 518a1f, checked in by Jens Schmidt <schmidt@…>, 26 years ago
* canonicalform.h (class CanonicalForm): friend declarations for `operator -', `operator +', `operator *', `operator /', `operator %', `div', `mod' replaced by ordinary declarations * canonicalform.cc, canonicalform.h (CanonicalForm, ~CanonicalForm, isOne, isZero, operator =): definitions of methods moved to `cf_inline.cc'. Declarations marked as `CF_INLINE' or `CF_NO_INLINE', resp. (operator -, operator +, operator *, operator /, operator %, div, mod): definitions of operators moved to `cf_inline.cc'. Declarations marked as `CF_INLINE' or `CF_NO_INLINE', resp. * canonicalform.h (CF_INLINE, CF_NO_INLINE): new #defines. `cf_iter_inline.cc' (conditionally) #included. git-svn-id: file:///usr/local/Singular/svn/trunk@2253 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.1 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: canonicalform.h,v 1.25 1998-06-29 14:37:00 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
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    friend ostream& operator << ( ostream&, const CanonicalForm& );
150    friend istream& operator >> ( istream&, CanonicalForm& );
151#endif /* NOSTREAMIO */
152
153    // obsolete methods
154    static CanonicalForm genCoeff( int what, int i = 0 );
155    CanonicalForm genZero() const;
156    CanonicalForm genOne() const;
157
158    friend class CFIterator;
159};
160//}}}
161
162CF_INLINE CanonicalForm
163operator + ( const CanonicalForm&, const CanonicalForm& );
164
165CF_NO_INLINE CanonicalForm
166operator - ( const CanonicalForm&, const CanonicalForm& );
167
168CF_INLINE CanonicalForm
169operator * ( const CanonicalForm&, const CanonicalForm& );
170
171CF_NO_INLINE CanonicalForm
172operator / ( const CanonicalForm&, const CanonicalForm& );
173
174CF_NO_INLINE CanonicalForm
175operator % ( const CanonicalForm&, const CanonicalForm& );
176
177CF_NO_INLINE CanonicalForm
178div ( const CanonicalForm&, const CanonicalForm& );
179
180CF_NO_INLINE CanonicalForm
181mod ( const CanonicalForm&, const CanonicalForm& );
182
183/*ENDPUBLIC*/
184
185#ifdef CF_USE_INLINE
186#include "cf_inline.cc"
187#endif
188
189/*BEGINPUBLIC*/
190
191//{{{ function declarations from canonicalform.cc
192CanonicalForm blcm ( const CanonicalForm & f, const CanonicalForm & g );
193
194CanonicalForm power ( const CanonicalForm & f, int n );
195
196CanonicalForm power ( const Variable & v, int n );
197//}}}
198
199//{{{ function declarations from cf_gcd.cc
200CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
201
202CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
203
204CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
205
206CanonicalForm pp ( const CanonicalForm& );
207
208CanonicalForm content ( const CanonicalForm& );
209
210CanonicalForm content ( const CanonicalForm&, const Variable& );
211
212CanonicalForm icontent ( const CanonicalForm & f );
213//}}}
214
215//{{{ function declarations from cf_ops.cc
216CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & );
217
218CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & );
219
220int getNumVars( const CanonicalForm & f );
221
222CanonicalForm getVars( const CanonicalForm & f );
223
224CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
225
226CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
227
228int * degrees ( const CanonicalForm & f, int * degs = 0 );
229
230int totaldegree ( const CanonicalForm & f );
231
232int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
233
234int size ( const CanonicalForm & f, const Variable & v );
235
236int size ( const CanonicalForm & f );
237//}}}
238
239//{{{ inline functions corresponding to CanonicalForm methods
240//{{{ docu
241//
242// - inline functions corresponding to CanonicalForm methods.
243//
244// These function exist for convenience only and because it is
245// more beautiful to write 'degree( f )' than 'f.degree()'.
246//
247//}}}
248inline CanonicalForm
249lc ( const CanonicalForm & f ) { return f.lc(); }
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, const Variable & v ) { return f.LC( v ); }
259
260inline int
261degree ( const CanonicalForm & f ) { return f.degree(); }
262
263inline int
264degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
265
266inline int
267taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
268
269inline CanonicalForm
270tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
271
272inline int
273level ( const CanonicalForm & f ) { return f.level(); }
274
275inline Variable
276mvar ( const CanonicalForm & f ) { return f.mvar(); }
277
278inline CanonicalForm
279num ( const CanonicalForm & f ) { return f.num(); }
280
281inline CanonicalForm
282den ( const CanonicalForm & f ) { return f.den(); }
283
284inline int
285sign ( const CanonicalForm & a ) { return a.sign(); }
286
287inline CanonicalForm
288deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); }
289
290inline CanonicalForm
291sqrt ( const CanonicalForm & a ) { return a.sqrt(); }
292
293inline int
294ilog2 ( const CanonicalForm & a ) { return a.ilog2(); }
295
296inline CanonicalForm
297mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
298//}}}
299
300//{{{ inline functions
301inline CanonicalForm
302head ( const CanonicalForm & f )
303{
304    if ( f.level() > 0 )
305        return power( f.mvar(), f.degree() ) * f.LC();
306    else
307        return f;
308}
309
310inline int
311headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
312//}}}
313
314//{{{ other function declarations
315void setCharacteristic( int c ); // -> Fp && Q
316void setCharacteristic( int c, int n ); // -> PrimePower
317void setCharacteristic( int c, int n, char name ); // -> GF(q)
318
319int getCharacteristic();
320int getGFDegree();
321CanonicalForm getGFGenerator();
322
323void On( int );
324void Off( int );
325bool isOn( int );
326//}}}
327
328//{{{ type definitions
329typedef Factor<CanonicalForm> CFFactor;
330typedef List<CFFactor> CFFList;
331typedef ListIterator<CFFactor> CFFListIterator;
332typedef List<CanonicalForm> CFList;
333typedef ListIterator<CanonicalForm> CFListIterator;
334typedef Array<CanonicalForm> CFArray;
335typedef Matrix<CanonicalForm> CFMatrix;
336//}}}
337
338/*ENDPUBLIC*/
339
340#endif /* ! INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.