source: git/factory/canonicalform.h @ 23ff95

spielwiese
Last change on this file since 23ff95 was 23ff95, checked in by Jens Schmidt <schmidt@…>, 27 years ago
* canonicalform.h: include paths for mac added git-svn-id: file:///usr/local/Singular/svn/trunk@454 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.8 1997-06-30 15:39:26 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    static CanonicalForm genCoeff( int what, int i = 0 );
84
85    CanonicalForm genZero() const;
86    CanonicalForm genOne() const;
87
88    bool isUnivariate() const;
89
90    bool inZ() const;
91    bool inQ() const;
92    bool inFF() const;
93    bool inGF() const;
94    bool inPP() const;
95    bool inBaseDomain() const;
96    bool inExtension() const;
97    bool inCoeffDomain() const;
98    bool inPolyDomain() const;
99    bool inQuotDomain() const;
100
101    CanonicalForm mapinto () const;
102
103    CanonicalForm operator () ( const CanonicalForm & f ) const;
104    CanonicalForm operator () ( const CanonicalForm & f, const Variable & v ) const;
105    CanonicalForm operator [] ( int i ) const;
106    CanonicalForm& operator = ( const CanonicalForm& );
107    CanonicalForm& operator = ( const int );
108
109    CanonicalForm& operator += ( const CanonicalForm& );
110    CanonicalForm& operator -= ( const CanonicalForm& );
111    CanonicalForm& operator *= ( const CanonicalForm& );
112    CanonicalForm& operator /= ( const CanonicalForm& );
113    CanonicalForm& operator %= ( const CanonicalForm& );
114    CanonicalForm& div ( const CanonicalForm& );
115    CanonicalForm& mod ( const CanonicalForm& );
116
117    friend CanonicalForm operator - ( const CanonicalForm& );
118
119    friend CanonicalForm operator + ( const CanonicalForm&, const CanonicalForm& );
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
125    friend CanonicalForm div ( const CanonicalForm&, const CanonicalForm& );
126    friend CanonicalForm mod ( const CanonicalForm&, const CanonicalForm& );
127
128    friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
129    friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
130
131#ifndef NOSTREAMIO
132    void print( ostream&, char * ) const;
133    friend ostream& operator << ( ostream&, const CanonicalForm& );
134    friend istream& operator >> ( istream&, CanonicalForm& );
135#endif /* NOSTREAMIO */
136
137    friend bool operator == ( const CanonicalForm&, const CanonicalForm& );
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
142    friend class CFIterator;
143};
144
145// some useful functions
146
147inline CanonicalForm
148lc ( const CanonicalForm & f ) { return f.lc(); }
149
150inline CanonicalForm
151LC ( const CanonicalForm & f ) { return f.LC(); }
152
153inline CanonicalForm
154LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
155
156inline int
157degree ( const CanonicalForm & f ) { return f.degree(); }
158
159inline int
160degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
161
162int totaldegree ( const CanonicalForm & f );
163
164int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
165
166inline int
167taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
168
169inline CanonicalForm
170tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
171
172CanonicalForm power ( const CanonicalForm & f, int n );
173
174CanonicalForm power ( const Variable & v, int n );
175
176inline CanonicalForm
177head ( const CanonicalForm & f )
178{
179    if ( f.level() > 0 )
180        return power( f.mvar(), f.degree() ) * f.LC();
181    else
182        return f;
183}
184
185inline int
186headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
187
188inline int
189level ( const CanonicalForm & f ) { return f.level(); }
190
191inline CanonicalForm
192mvar ( const CanonicalForm & f ) { return f.mvar(); }
193
194inline CanonicalForm
195num ( const CanonicalForm & f ) { return f.num(); }
196
197inline CanonicalForm
198den ( const CanonicalForm & f ) { return f.den(); }
199
200inline CanonicalForm
201mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
202
203CanonicalForm swapvar ( const CanonicalForm&, const Variable&, const Variable& );
204
205CanonicalForm resultant( const CanonicalForm & f, const CanonicalForm& g, const Variable & x );
206
207CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
208
209CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
210
211CanonicalForm iextgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
212
213CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
214
215CanonicalForm common_den ( const CanonicalForm& );
216
217CanonicalForm pp ( const CanonicalForm& );
218
219CanonicalForm content ( const CanonicalForm& );
220
221CanonicalForm content ( const CanonicalForm&, const Variable& );
222
223CanonicalForm icontent ( const CanonicalForm & f );
224
225CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
226
227CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
228
229bool divides ( const CanonicalForm & f, const CanonicalForm & g );
230
231inline CanonicalForm
232deriv ( const CanonicalForm & f, const Variable & x )
233{
234    return f.deriv(x);
235}
236
237inline CanonicalForm
238abs ( const CanonicalForm & f )
239{
240    if ( f < 0 )
241        return -f;
242    else
243        return f;
244}
245
246inline CanonicalForm
247sqrt ( const CanonicalForm & a )
248{
249    return a.sqrt();
250}
251
252
253CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x  );
254
255CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x );
256
257void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x );
258
259int getNumVars( const CanonicalForm & f );
260CanonicalForm getVars( const CanonicalForm & f );
261
262int * degrees ( const CanonicalForm & f, int * degs = 0 );
263
264//CanonicalForm norm( const CanonicalForm & );
265
266//CanonicalForm igcd( const CanonicalForm & );
267
268//CanonicalForm ff2z( const CanonicalForm & );
269//CanonicalForm z2ff( const CanonicalForm & );
270
271void setCharacteristic( int c ); // -> Fp && Q
272void setCharacteristic( int c, int n ); // -> PrimePower
273void setCharacteristic( int c, int n, char name ); // -> GF(q)
274
275int getCharacteristic();
276int getGFDegree();
277
278CanonicalForm getGFGenerator();
279
280// misc template stuff for inst file
281
282typedef Factor<CanonicalForm> CFFactor;
283typedef List<CFFactor> CFFList;
284typedef ListIterator<CFFactor> CFFListIterator;
285typedef List<CanonicalForm> CFList;
286typedef ListIterator<CanonicalForm> CFListIterator;
287typedef Array<CanonicalForm> CFArray;
288typedef Matrix<CanonicalForm> CFMatrix;
289
290CFFList sqrFree ( const CanonicalForm & f, bool sort );
291
292CFFList sqrFree( const CanonicalForm & f );
293
294bool isSqrFree( const CanonicalForm & f );
295
296CFFList factorize( const CanonicalForm & f, bool issqrfree = false );
297
298CFFList factorize( const CanonicalForm & f, const Variable & alpha );
299
300// calculate the determinant of the n'th minor of M
301
302bool linearSystemSolve( CFMatrix & M );
303
304CanonicalForm determinant( const CFMatrix & M, int n );
305
306void On( int );
307void Off( int );
308bool isOn( int );
309
310/*ENDPUBLIC*/
311
312#endif /* ! INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.