source: git/factory/canonicalform.h @ a3bc35a

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