source: git/factory/canonicalform.h @ 8c6a0fa

fieker-DuValspielwiese
Last change on this file since 8c6a0fa was 6400f5, checked in by Hans Schönemann <hannes@…>, 24 years ago
* hannes: added dummy routines for debuuging factory/libfac (Singular/claptmpl.cc Singular/fglm.cc Singular/fglm.h Singular/fglmvec.cc Singular/fglmzero.cc Singular/iparith.cc Singular/static.h factory/canonicalform.cc factory/canonicalform.h factory/cf_eval.cc factory/cf_map.cc factory/cf_map.h libfac/charset/charset.cc) git-svn-id: file:///usr/local/Singular/svn/trunk@4409 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.26 2000-05-29 15:05:20 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//}}}
215
216//{{{ function declarations from cf_ops.cc
217CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & );
218
219CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & );
220
221int getNumVars( const CanonicalForm & f );
222
223CanonicalForm getVars( const CanonicalForm & f );
224
225CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
226
227CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
228
229int * degrees ( const CanonicalForm & f, int * degs = 0 );
230
231int totaldegree ( const CanonicalForm & f );
232
233int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
234
235int size ( const CanonicalForm & f, const Variable & v );
236
237int size ( const CanonicalForm & f );
238//}}}
239
240//{{{ inline functions corresponding to CanonicalForm methods
241//{{{ docu
242//
243// - inline functions corresponding to CanonicalForm methods.
244//
245// These function exist for convenience only and because it is
246// more beautiful to write 'degree( f )' than 'f.degree()'.
247//
248//}}}
249inline CanonicalForm
250lc ( const CanonicalForm & f ) { return f.lc(); }
251
252inline CanonicalForm
253Lc ( const CanonicalForm & f ) { return f.Lc(); }
254
255inline CanonicalForm
256LC ( const CanonicalForm & f ) { return f.LC(); }
257
258inline CanonicalForm
259LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
260
261inline int
262degree ( const CanonicalForm & f ) { return f.degree(); }
263
264inline int
265degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
266
267inline int
268taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
269
270inline CanonicalForm
271tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
272
273inline int
274level ( const CanonicalForm & f ) { return f.level(); }
275
276inline Variable
277mvar ( const CanonicalForm & f ) { return f.mvar(); }
278
279inline CanonicalForm
280num ( const CanonicalForm & f ) { return f.num(); }
281
282inline CanonicalForm
283den ( const CanonicalForm & f ) { return f.den(); }
284
285inline int
286sign ( const CanonicalForm & a ) { return a.sign(); }
287
288inline CanonicalForm
289deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); }
290
291inline CanonicalForm
292sqrt ( const CanonicalForm & a ) { return a.sqrt(); }
293
294inline int
295ilog2 ( const CanonicalForm & a ) { return a.ilog2(); }
296
297inline CanonicalForm
298mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
299//}}}
300
301//{{{ inline functions
302inline CanonicalForm
303head ( const CanonicalForm & f )
304{
305    if ( f.level() > 0 )
306        return power( f.mvar(), f.degree() ) * f.LC();
307    else
308        return f;
309}
310
311inline int
312headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
313//}}}
314
315//{{{ other function declarations
316void setCharacteristic( int c ); // -> Fp && Q
317void setCharacteristic( int c, int n ); // -> PrimePower
318void setCharacteristic( int c, int n, char name ); // -> GF(q)
319
320int getCharacteristic();
321int getGFDegree();
322CanonicalForm getGFGenerator();
323
324void On( int );
325void Off( int );
326bool isOn( int );
327//}}}
328
329//{{{ type definitions
330typedef Factor<CanonicalForm> CFFactor;
331typedef List<CFFactor> CFFList;
332typedef ListIterator<CFFactor> CFFListIterator;
333typedef List<CanonicalForm> CFList;
334typedef ListIterator<CanonicalForm> CFListIterator;
335typedef Array<CanonicalForm> CFArray;
336typedef Matrix<CanonicalForm> CFMatrix;
337//}}}
338
339/*ENDPUBLIC*/
340
341#endif /* ! INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.