source: git/factory/canonicalform.h @ f3b98ad

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