source: git/factory/canonicalform.h @ 95f247

spielwiese
Last change on this file since 95f247 was 95f247, checked in by Rüdiger Stobbe <stobbe@…>, 28 years ago
"new function determinant. new template class Matrix<CanonicalForm> " git-svn-id: file:///usr/local/Singular/svn/trunk@28 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.5 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2// $Id: canonicalform.h,v 1.1 1996-06-24 11:26:36 stobbe Exp $
3
4#ifndef INCL_CANONICALFORM_H
5#define INCL_CANONICALFORM_H
6
7/*
8$Log: not supported by cvs2svn $
9Revision 1.0  1996/05/17 10:59:37  stobbe
10Initial revision
11
12*/
13
14#include <iostream.h>
15
16#include "cf_defs.h"
17#include "variable.h"
18#include "templates/list.h"
19#include "templates/array.h"
20#include "templates/factor.h"
21#include "templates/matrix.h"
22
23/*BEGINPUBLIC*/
24
25int initCanonicalForm( void );
26
27static int cf_is_initialized_now = initCanonicalForm();
28
29class InternalCF;
30
31class CanonicalForm {
32private:
33    InternalCF *value;
34public:
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    int sign() const;
48
49    bool isOne() const;
50    bool isZero() const;
51    bool isImm() const;
52
53    int intval() const;
54
55    CanonicalForm lc() const;
56    CanonicalForm LC() const;
57    CanonicalForm LC( const Variable & v ) const;
58
59    int degree() const;
60    int degree( const Variable & v ) const;
61
62    CanonicalForm tailcoeff() const;
63    int taildegree() const;
64
65    int level() const;
66    Variable mvar() const;
67
68    CanonicalForm num() const;
69    CanonicalForm den() const;
70
71    CanonicalForm deepCopy() const;
72
73    bool isFFinGF() const;
74    bool hasGcd() const { return false; }
75    CanonicalForm gcd( const CanonicalForm & f ) const;
76    CanonicalForm deriv() const;
77    CanonicalForm deriv( const Variable & x ) const;
78    CanonicalForm sqrt() const;
79    static CanonicalForm genCoeff( int what, int i = 0 );
80
81    CanonicalForm genZero() const;
82    CanonicalForm genOne() const;
83
84    bool isUnivariate() const;
85
86    bool inZ() const;
87    bool inQ() const;
88    bool inFF() const;
89    bool inGF() const;
90    bool inPP() const;
91    bool inBaseDomain() const;
92    bool inExtension() const;
93    bool inCoeffDomain() const;
94    bool inPolyDomain() const;
95    bool inQuotDomain() const;
96
97    CanonicalForm mapinto () const;
98
99    CanonicalForm operator () ( const CanonicalForm & f ) const;
100    CanonicalForm operator () ( const CanonicalForm & f, const Variable & v ) const;
101    CanonicalForm operator [] ( int i ) const;
102    CanonicalForm& operator = ( const CanonicalForm& );
103    CanonicalForm& operator = ( const int );
104
105    CanonicalForm& operator += ( const CanonicalForm& );
106    CanonicalForm& operator -= ( const CanonicalForm& );
107    CanonicalForm& operator *= ( const CanonicalForm& );
108    CanonicalForm& operator /= ( const CanonicalForm& );
109    CanonicalForm& operator %= ( const CanonicalForm& );
110    CanonicalForm& div ( const CanonicalForm& );
111    CanonicalForm& mod ( const CanonicalForm& );
112
113    friend CanonicalForm operator - ( const CanonicalForm& ); 
114
115    friend CanonicalForm operator + ( const CanonicalForm&, const CanonicalForm& );
116    friend CanonicalForm operator - ( const CanonicalForm&, const CanonicalForm& );
117    friend CanonicalForm operator * ( const CanonicalForm&, const CanonicalForm& );
118    friend CanonicalForm operator / ( const CanonicalForm&, const CanonicalForm& );
119    friend CanonicalForm operator % ( const CanonicalForm&, const CanonicalForm& );
120
121    friend CanonicalForm div ( const CanonicalForm&, const CanonicalForm& );
122    friend CanonicalForm mod ( const CanonicalForm&, const CanonicalForm& );
123
124    friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
125    friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
126
127    void print( ostream&, char * ) const;
128    friend ostream& operator << ( ostream&, const CanonicalForm& );
129    friend istream& operator >> ( istream&, CanonicalForm& );
130
131    friend bool operator == ( const CanonicalForm&, const CanonicalForm& );
132    friend bool operator != ( const CanonicalForm&, const CanonicalForm& );
133    friend bool operator > ( const CanonicalForm&, const CanonicalForm& );
134    friend bool operator < ( const CanonicalForm&, const CanonicalForm& );
135
136    friend class CFIterator;
137};
138
139// some useful functions
140
141inline CanonicalForm
142lc ( const CanonicalForm & f ) { return f.lc(); }
143
144inline CanonicalForm
145LC ( const CanonicalForm & f ) { return f.LC(); }
146
147inline CanonicalForm
148LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
149
150inline int
151degree ( const CanonicalForm & f ) { return f.degree(); }
152
153inline int
154degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
155
156int totaldegree ( const CanonicalForm & f );
157
158int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
159
160inline int
161taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
162
163inline CanonicalForm
164tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
165
166CanonicalForm power ( const CanonicalForm & f, int n );
167
168CanonicalForm power ( const Variable & v, int n );
169
170inline CanonicalForm
171head ( const CanonicalForm & f )
172{
173    if ( f.level() > 0 )
174        return power( f.mvar(), f.degree() ) * f.LC();
175    else
176        return f;
177}
178
179inline int
180headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
181
182inline int
183level ( const CanonicalForm & f ) { return f.level(); }
184
185inline CanonicalForm
186mvar ( const CanonicalForm & f ) { return f.mvar(); }
187
188inline CanonicalForm
189num ( const CanonicalForm & f ) { return f.num(); }
190
191inline CanonicalForm
192den ( const CanonicalForm & f ) { return f.den(); }
193
194inline CanonicalForm
195mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
196
197CanonicalForm swapvar ( const CanonicalForm&, const Variable&, const Variable& );
198
199CanonicalForm resultant( const CanonicalForm & f, const CanonicalForm& g, const Variable & x );
200
201CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
202
203CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
204
205CanonicalForm iextgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
206
207CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
208
209CanonicalForm common_den ( const CanonicalForm& );
210
211CanonicalForm pp ( const CanonicalForm& );
212
213CanonicalForm content ( const CanonicalForm& );
214
215CanonicalForm content ( const CanonicalForm&, const Variable& );
216
217CanonicalForm icontent ( const CanonicalForm & f );
218
219CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
220
221CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
222
223bool divides ( const CanonicalForm & f, const CanonicalForm & g );
224
225inline CanonicalForm
226deriv ( const CanonicalForm & f, const Variable & x )
227{
228    return f.deriv(x);
229}
230
231inline CanonicalForm
232abs ( const CanonicalForm & f )
233{
234    if ( f < 0 )
235        return -f;
236    else
237        return f;
238}
239
240inline CanonicalForm
241sqrt ( const CanonicalForm & a )
242{
243    return a.sqrt();
244}
245
246
247CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x  );
248
249CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x );
250
251void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x );
252
253int getNumVars( const CanonicalForm & f );
254CanonicalForm getVars( const CanonicalForm & f );
255
256int * degrees ( const CanonicalForm & f, int * degs = 0 );
257
258//CanonicalForm norm( const CanonicalForm & );
259
260//CanonicalForm igcd( const CanonicalForm & );
261
262//CanonicalForm ff2z( const CanonicalForm & );
263//CanonicalForm z2ff( const CanonicalForm & );
264
265void setCharacteristic( int c ); // -> Fp && Q
266void setCharacteristic( int c, int n ); // -> PrimePower
267void setCharacteristic( int c, int n, char name ); // -> GF(q)
268
269int getCharacteristic();
270int getGFDegree();
271
272CanonicalForm getGFGenerator();
273
274// misc template stuff for inst file
275
276typedef Factor<CanonicalForm> CFFactor;
277typedef List<CFFactor> CFFList;
278typedef ListIterator<CFFactor> CFFListIterator;
279typedef List<CanonicalForm> CFList;
280typedef ListIterator<CanonicalForm> CFListIterator;
281typedef Array<CanonicalForm> CFArray;
282typedef Matrix<CanonicalForm> CFMatrix;
283
284CFFList sqrFree( const CanonicalForm & f );
285
286bool isSqrFree( const CanonicalForm & f );
287
288CFFList factorize( const CanonicalForm & f, bool issqrfree = false );
289
290CFFList factorize( const CanonicalForm & f, const Variable & alpha );
291
292// calculate the determinant of the n'th minor of M
293
294CanonicalForm determinant( const CFMatrix & M, int n );
295
296void On( int );
297void Off( int );
298bool isOn( int );
299
300/*ENDPUBLIC*/
301
302#endif /* INCL_CANONICALFORM_H */
Note: See TracBrowser for help on using the repository browser.