source: git/factory/canonicalform.h @ 5ed8ad

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