source: git/factory/canonicalform.h @ bbe7bc

spielwiese
Last change on this file since bbe7bc was bbe7bc, checked in by Jens Schmidt <schmidt@…>, 27 years ago
* canonicalform.cc (Lc): new method. Declaration added. git-svn-id: file:///usr/local/Singular/svn/trunk@799 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.9 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: canonicalform.h,v 1.18 1997-10-10 10:39:52 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    bool hasGcd() const { return false; }
121    CanonicalForm gcd( const CanonicalForm & f ) const;
122
123    // comparison operators
124    friend bool operator == ( const CanonicalForm&, const CanonicalForm& );
125    friend bool operator != ( const CanonicalForm&, const CanonicalForm& );
126    friend bool operator > ( const CanonicalForm&, const CanonicalForm& );
127    friend bool operator < ( const CanonicalForm&, const CanonicalForm& );
128
129    // arithmetic operators
130    friend CanonicalForm operator - ( const CanonicalForm& );
131
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    friend CanonicalForm operator / ( const CanonicalForm&, const CanonicalForm& );
136    friend CanonicalForm operator % ( const CanonicalForm&, const CanonicalForm& );
137
138    friend CanonicalForm div ( const CanonicalForm&, const CanonicalForm& );
139    friend CanonicalForm mod ( const CanonicalForm&, const CanonicalForm& );
140
141    friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
142    friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
143
144#ifndef NOSTREAMIO
145    void print( ostream&, char * ) const;
146    friend ostream& operator << ( ostream&, const CanonicalForm& );
147    friend istream& operator >> ( istream&, CanonicalForm& );
148#endif /* NOSTREAMIO */
149
150    // obsolete methods
151    static CanonicalForm genCoeff( int what, int i = 0 );
152    CanonicalForm genZero() const;
153    CanonicalForm genOne() const;
154
155    friend class CFIterator;
156};
157//}}}
158
159// some useful functions
160
161//{{{ function declarations from canonicalform.cc
162CanonicalForm power ( const CanonicalForm & f, int n );
163
164CanonicalForm power ( const Variable & v, int n );
165
166bool divides ( const CanonicalForm & f, const CanonicalForm & g );
167//}}}
168
169//{{{ function declarations from cf_gcd.cc
170CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
171
172CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
173
174CanonicalForm iextgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
175
176CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
177
178CanonicalForm pp ( const CanonicalForm& );
179
180CanonicalForm content ( const CanonicalForm& );
181
182CanonicalForm content ( const CanonicalForm&, const Variable& );
183
184CanonicalForm icontent ( const CanonicalForm & f );
185//}}}
186
187//{{{ function declarations from cf_ops.cc
188CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & );
189
190CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & );
191
192int getNumVars( const CanonicalForm & f );
193
194CanonicalForm getVars( const CanonicalForm & f );
195
196CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
197
198CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
199
200int * degrees ( const CanonicalForm & f, int * degs = 0 );
201
202int totaldegree ( const CanonicalForm & f );
203
204int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
205
206int size ( const CanonicalForm & f, const Variable & v );
207
208int size ( const CanonicalForm & f );
209//}}}
210
211//{{{ inline functions corresponding to CanonicalForm methods
212//{{{ docu
213//
214// - inline functions corresponding to CanonicalForm methods.
215//
216// These function exist for convenience only and because it is
217// more beautiful to write 'degree( f )' than 'f.degree()'.
218//
219//}}}
220inline CanonicalForm
221lc ( const CanonicalForm & f ) { return f.lc(); }
222
223inline CanonicalForm
224Lc ( const CanonicalForm & f ) { return f.Lc(); }
225
226inline CanonicalForm
227LC ( const CanonicalForm & f ) { return f.LC(); }
228
229inline CanonicalForm
230LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
231
232inline int
233degree ( const CanonicalForm & f ) { return f.degree(); }
234
235inline int
236degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
237
238inline int
239taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
240
241inline CanonicalForm
242tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
243
244inline int
245level ( const CanonicalForm & f ) { return f.level(); }
246
247inline CanonicalForm
248mvar ( const CanonicalForm & f ) { return f.mvar(); }
249
250inline CanonicalForm
251num ( const CanonicalForm & f ) { return f.num(); }
252
253inline CanonicalForm
254den ( const CanonicalForm & f ) { return f.den(); }
255
256inline CanonicalForm
257deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); }
258
259inline CanonicalForm
260sqrt ( const CanonicalForm & a ) { return a.sqrt(); }
261
262inline int
263ilog2 ( const CanonicalForm & a ) { return a.ilog2(); }
264
265inline CanonicalForm
266mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
267//}}}
268
269//{{{ inline functions
270inline CanonicalForm
271head ( const CanonicalForm & f )
272{
273    if ( f.level() > 0 )
274        return power( f.mvar(), f.degree() ) * f.LC();
275    else
276        return f;
277}
278
279inline CanonicalForm
280abs ( const CanonicalForm & f )
281{
282    if ( f < 0 )
283        return -f;
284    else
285        return f;
286}
287
288inline int
289headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
290//}}}
291
292//{{{ other function declarations
293void setCharacteristic( int c ); // -> Fp && Q
294void setCharacteristic( int c, int n ); // -> PrimePower
295void setCharacteristic( int c, int n, char name ); // -> GF(q)
296
297int getCharacteristic();
298int getGFDegree();
299CanonicalForm getGFGenerator();
300
301void On( int );
302void Off( int );
303bool isOn( int );
304//}}}
305
306//{{{ type definitions
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//}}}
315
316/*ENDPUBLIC*/
317
318#endif /* ! INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.