1 | /* ../factory/winnt/factory.h automatically generated by makeheader from ../factory/factory.template */ |
---|
2 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
3 | /* $Id: factory.h,v 1.4 1997-12-09 12:00:01 schmidt Exp $ */ |
---|
4 | |
---|
5 | #ifndef INCL_FACTORY_H |
---|
6 | #define INCL_FACTORY_H |
---|
7 | |
---|
8 | //{{{ docu |
---|
9 | // |
---|
10 | // factory.template - template to generate `factory.h'. |
---|
11 | // |
---|
12 | // `factory.h' is the user interface to Factory. Created |
---|
13 | // automatically by `makeheader', it collects all important |
---|
14 | // declarations from all important Factory header files into one |
---|
15 | // overall header file leaving out all boring Factory internal |
---|
16 | // stuff. See `./bin/makeheader' for an explanation of the syntax |
---|
17 | // of this file. |
---|
18 | // |
---|
19 | // Note: In this file the order of "includes" matters (since this |
---|
20 | // are not real includes)! In general, files at the end depend |
---|
21 | // on files at the beginning. |
---|
22 | // |
---|
23 | //}}} |
---|
24 | |
---|
25 | #include <factoryconf.h> |
---|
26 | |
---|
27 | #ifndef NOSTREAMIO |
---|
28 | #include <iostream.h> |
---|
29 | #endif /* ! NOSTREAMIO */ |
---|
30 | |
---|
31 | #ifdef SINGULAR |
---|
32 | extern "C" { |
---|
33 | #include <gmp.h> |
---|
34 | } |
---|
35 | #endif /* SINGULAR */ |
---|
36 | |
---|
37 | #ifdef macintosh |
---|
38 | #include <::templates:ftmpl_array.h> |
---|
39 | #include <::templates:ftmpl_factor.h> |
---|
40 | #include <::templates:ftmpl_list.h> |
---|
41 | #include <::templates:ftmpl_matrix.h> |
---|
42 | #else |
---|
43 | #include <templates/ftmpl_array.h> |
---|
44 | #include <templates/ftmpl_factor.h> |
---|
45 | #include <templates/ftmpl_list.h> |
---|
46 | #include <templates/ftmpl_matrix.h> |
---|
47 | #endif |
---|
48 | |
---|
49 | /* stuff included from ../factory/cf_globals.h */ |
---|
50 | |
---|
51 | |
---|
52 | extern const char factoryVersion[]; |
---|
53 | extern const char factoryConfiguration[]; |
---|
54 | |
---|
55 | |
---|
56 | /* stuff included from ../factory/cf_primes.h */ |
---|
57 | |
---|
58 | |
---|
59 | int cf_getPrime( int i ); |
---|
60 | |
---|
61 | int cf_getNumPrimes(); |
---|
62 | |
---|
63 | int cf_getSmallPrime( int i ); |
---|
64 | |
---|
65 | int cf_getNumSmallPrimes(); |
---|
66 | |
---|
67 | int cf_getBigPrime( int i ); |
---|
68 | |
---|
69 | int cf_getNumBigPrimes(); |
---|
70 | |
---|
71 | |
---|
72 | /* stuff included from ../factory/cf_defs.h */ |
---|
73 | |
---|
74 | |
---|
75 | #define LEVELBASE -1000000 |
---|
76 | #define LEVELTRANS -500000 |
---|
77 | #define LEVELQUOT 1000000 |
---|
78 | #define LEVELEXPR 1000001 |
---|
79 | |
---|
80 | #define UndefinedDomain 32000 |
---|
81 | #define PrimePowerDomain 5 |
---|
82 | #define GaloisFieldDomain 4 |
---|
83 | #define FiniteFieldDomain 3 |
---|
84 | #define RationalDomain 2 |
---|
85 | #define IntegerDomain 1 |
---|
86 | |
---|
87 | //{{{ constants |
---|
88 | //{{{ docu |
---|
89 | // |
---|
90 | // - factory switches. |
---|
91 | // |
---|
92 | //}}} |
---|
93 | const int SW_RATIONAL = 0; |
---|
94 | const int SW_QUOTIENT = 1; |
---|
95 | const int SW_SYMMETRIC_FF = 2; |
---|
96 | const int SW_BERLEKAMP = 3; |
---|
97 | const int SW_FAC_USE_BIG_PRIMES = 4; |
---|
98 | const int SW_FAC_QUADRATICLIFT = 5; |
---|
99 | const int SW_USE_EZGCD = 6; |
---|
100 | const int SW_USE_SPARSEMOD = 7; |
---|
101 | //}}} |
---|
102 | |
---|
103 | |
---|
104 | /* stuff included from ../factory/variable.h */ |
---|
105 | |
---|
106 | |
---|
107 | class CanonicalForm; |
---|
108 | |
---|
109 | class Variable |
---|
110 | { |
---|
111 | private: |
---|
112 | int _level; |
---|
113 | Variable( int l, bool flag ); |
---|
114 | public: |
---|
115 | Variable() : _level(LEVELBASE) {} |
---|
116 | Variable( int l ); |
---|
117 | Variable( char name ); |
---|
118 | Variable( int l, char name ); |
---|
119 | Variable( const Variable & v ) : _level(v._level) {} |
---|
120 | ~Variable() {}; |
---|
121 | Variable& operator= ( const Variable & v ) |
---|
122 | { |
---|
123 | _level = v._level; |
---|
124 | return *this; |
---|
125 | } |
---|
126 | int level() const { return _level; } |
---|
127 | char name() const; |
---|
128 | static Variable highest() { return Variable( LEVELQUOT-1 ); } |
---|
129 | Variable next() const { return Variable( _level+1 ); } |
---|
130 | friend bool operator == ( const Variable & lhs, const Variable & rhs ) |
---|
131 | { |
---|
132 | return lhs._level == rhs._level; |
---|
133 | } |
---|
134 | friend bool operator != ( const Variable & lhs, const Variable & rhs ) |
---|
135 | { |
---|
136 | return lhs._level != rhs._level; |
---|
137 | } |
---|
138 | friend bool operator > ( const Variable & lhs, const Variable & rhs ) |
---|
139 | { |
---|
140 | return lhs._level > rhs._level; |
---|
141 | } |
---|
142 | friend bool operator < ( const Variable & lhs, const Variable & rhs ) |
---|
143 | { |
---|
144 | return lhs._level < rhs._level; |
---|
145 | } |
---|
146 | friend bool operator >= ( const Variable & lhs, const Variable & rhs ) |
---|
147 | { |
---|
148 | return lhs._level >= rhs._level; |
---|
149 | } |
---|
150 | friend bool operator <= ( const Variable & lhs, const Variable & rhs ) |
---|
151 | { |
---|
152 | return lhs._level <= rhs._level; |
---|
153 | } |
---|
154 | #ifndef NOSTREAMIO |
---|
155 | friend ostream & operator << ( ostream & os, const Variable & v ); |
---|
156 | #endif /* NOSTREAMIO */ |
---|
157 | friend Variable rootOf( const CanonicalForm &, char name = '@' ); |
---|
158 | }; |
---|
159 | |
---|
160 | inline int level( const Variable & v ) { return v.level(); } |
---|
161 | inline char name( const Variable & v ) { return v.name(); } |
---|
162 | |
---|
163 | CanonicalForm getMipo( const Variable & alpha, const Variable & x ); |
---|
164 | |
---|
165 | char getDefaultVarName(); |
---|
166 | char getDefaultExtName(); |
---|
167 | |
---|
168 | |
---|
169 | /* stuff included from ../factory/canonicalform.h */ |
---|
170 | |
---|
171 | |
---|
172 | int initCanonicalForm( void ); |
---|
173 | |
---|
174 | static int cf_is_initialized_now = initCanonicalForm(); |
---|
175 | |
---|
176 | class InternalCF; |
---|
177 | |
---|
178 | //{{{ class CanonicalForm |
---|
179 | class CanonicalForm |
---|
180 | { |
---|
181 | private: |
---|
182 | InternalCF *value; |
---|
183 | public: |
---|
184 | // constructors, destructors, selectors |
---|
185 | CanonicalForm(); |
---|
186 | CanonicalForm( const CanonicalForm& ); |
---|
187 | CanonicalForm( InternalCF* ); |
---|
188 | CanonicalForm( const int ); |
---|
189 | CanonicalForm( const Variable & ); |
---|
190 | CanonicalForm( const Variable &, int ); |
---|
191 | CanonicalForm( const char * ); // use with caution - does only handle integers !!! |
---|
192 | |
---|
193 | ~CanonicalForm(); |
---|
194 | |
---|
195 | InternalCF* getval() const; // use with caution !!! |
---|
196 | |
---|
197 | CanonicalForm deepCopy() const; |
---|
198 | |
---|
199 | // predicates |
---|
200 | bool isOne() const; |
---|
201 | bool isZero() const; |
---|
202 | bool isImm() const; |
---|
203 | |
---|
204 | bool inZ() const; |
---|
205 | bool inQ() const; |
---|
206 | bool inFF() const; |
---|
207 | bool inGF() const; |
---|
208 | bool inPP() const; |
---|
209 | bool inBaseDomain() const; |
---|
210 | bool inExtension() const; |
---|
211 | bool inCoeffDomain() const; |
---|
212 | bool inPolyDomain() const; |
---|
213 | bool inQuotDomain() const; |
---|
214 | |
---|
215 | bool isFFinGF() const; |
---|
216 | bool isUnivariate() const; |
---|
217 | |
---|
218 | // conversion functions |
---|
219 | int intval() const; |
---|
220 | CanonicalForm mapinto () const; |
---|
221 | |
---|
222 | CanonicalForm lc () const; |
---|
223 | CanonicalForm Lc () const; |
---|
224 | CanonicalForm LC () const; |
---|
225 | CanonicalForm LC ( const Variable & v ) const; |
---|
226 | |
---|
227 | int degree () const; |
---|
228 | int degree ( const Variable & v ) const; |
---|
229 | |
---|
230 | CanonicalForm tailcoeff () const; |
---|
231 | int taildegree () const; |
---|
232 | |
---|
233 | int level () const; |
---|
234 | Variable mvar () const; |
---|
235 | |
---|
236 | CanonicalForm num () const; |
---|
237 | CanonicalForm den () const; |
---|
238 | |
---|
239 | // assignment operators |
---|
240 | CanonicalForm& operator = ( const CanonicalForm& ); |
---|
241 | CanonicalForm& operator = ( const int ); |
---|
242 | |
---|
243 | CanonicalForm& operator += ( const CanonicalForm& ); |
---|
244 | CanonicalForm& operator -= ( const CanonicalForm& ); |
---|
245 | CanonicalForm& operator *= ( const CanonicalForm& ); |
---|
246 | CanonicalForm& operator /= ( const CanonicalForm& ); |
---|
247 | CanonicalForm& operator %= ( const CanonicalForm& ); |
---|
248 | CanonicalForm& div ( const CanonicalForm& ); |
---|
249 | CanonicalForm& mod ( const CanonicalForm& ); |
---|
250 | |
---|
251 | // evaluation operators |
---|
252 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
253 | CanonicalForm operator () ( const CanonicalForm & f, const Variable & v ) const; |
---|
254 | |
---|
255 | CanonicalForm operator [] ( int i ) const; |
---|
256 | |
---|
257 | CanonicalForm deriv() const; |
---|
258 | CanonicalForm deriv( const Variable & x ) const; |
---|
259 | |
---|
260 | int sign() const; |
---|
261 | CanonicalForm sqrt() const; |
---|
262 | int ilog2() const; |
---|
263 | |
---|
264 | // comparison operators |
---|
265 | friend bool operator == ( const CanonicalForm&, const CanonicalForm& ); |
---|
266 | friend bool operator != ( const CanonicalForm&, const CanonicalForm& ); |
---|
267 | friend bool operator > ( const CanonicalForm&, const CanonicalForm& ); |
---|
268 | friend bool operator < ( const CanonicalForm&, const CanonicalForm& ); |
---|
269 | |
---|
270 | // arithmetic operators |
---|
271 | friend CanonicalForm operator - ( const CanonicalForm& ); |
---|
272 | |
---|
273 | friend CanonicalForm operator + ( const CanonicalForm&, const CanonicalForm& ); |
---|
274 | friend CanonicalForm operator - ( const CanonicalForm&, const CanonicalForm& ); |
---|
275 | friend CanonicalForm operator * ( const CanonicalForm&, const CanonicalForm& ); |
---|
276 | friend CanonicalForm operator / ( const CanonicalForm&, const CanonicalForm& ); |
---|
277 | friend CanonicalForm operator % ( const CanonicalForm&, const CanonicalForm& ); |
---|
278 | |
---|
279 | friend CanonicalForm div ( const CanonicalForm&, const CanonicalForm& ); |
---|
280 | friend CanonicalForm mod ( const CanonicalForm&, const CanonicalForm& ); |
---|
281 | |
---|
282 | friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
283 | friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
284 | |
---|
285 | #ifndef NOSTREAMIO |
---|
286 | void print( ostream&, char * ) const; |
---|
287 | friend ostream& operator << ( ostream&, const CanonicalForm& ); |
---|
288 | friend istream& operator >> ( istream&, CanonicalForm& ); |
---|
289 | #endif /* NOSTREAMIO */ |
---|
290 | |
---|
291 | // obsolete methods |
---|
292 | static CanonicalForm genCoeff( int what, int i = 0 ); |
---|
293 | CanonicalForm genZero() const; |
---|
294 | CanonicalForm genOne() const; |
---|
295 | |
---|
296 | friend class CFIterator; |
---|
297 | }; |
---|
298 | //}}} |
---|
299 | |
---|
300 | // some useful functions |
---|
301 | |
---|
302 | //{{{ function declarations from canonicalform.cc |
---|
303 | CanonicalForm power ( const CanonicalForm & f, int n ); |
---|
304 | |
---|
305 | CanonicalForm power ( const Variable & v, int n ); |
---|
306 | |
---|
307 | bool divides ( const CanonicalForm & f, const CanonicalForm & g ); |
---|
308 | //}}} |
---|
309 | |
---|
310 | //{{{ function declarations from cf_gcd.cc |
---|
311 | CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& ); |
---|
312 | |
---|
313 | CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
314 | |
---|
315 | CanonicalForm iextgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
316 | |
---|
317 | CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& ); |
---|
318 | |
---|
319 | CanonicalForm pp ( const CanonicalForm& ); |
---|
320 | |
---|
321 | CanonicalForm content ( const CanonicalForm& ); |
---|
322 | |
---|
323 | CanonicalForm content ( const CanonicalForm&, const Variable& ); |
---|
324 | |
---|
325 | CanonicalForm icontent ( const CanonicalForm & f ); |
---|
326 | //}}} |
---|
327 | |
---|
328 | //{{{ function declarations from cf_ops.cc |
---|
329 | CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & ); |
---|
330 | |
---|
331 | CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & ); |
---|
332 | |
---|
333 | int getNumVars( const CanonicalForm & f ); |
---|
334 | |
---|
335 | CanonicalForm getVars( const CanonicalForm & f ); |
---|
336 | |
---|
337 | CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) ); |
---|
338 | |
---|
339 | CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ); |
---|
340 | |
---|
341 | int * degrees ( const CanonicalForm & f, int * degs = 0 ); |
---|
342 | |
---|
343 | int totaldegree ( const CanonicalForm & f ); |
---|
344 | |
---|
345 | int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 ); |
---|
346 | |
---|
347 | int size ( const CanonicalForm & f, const Variable & v ); |
---|
348 | |
---|
349 | int size ( const CanonicalForm & f ); |
---|
350 | //}}} |
---|
351 | |
---|
352 | //{{{ inline functions corresponding to CanonicalForm methods |
---|
353 | //{{{ docu |
---|
354 | // |
---|
355 | // - inline functions corresponding to CanonicalForm methods. |
---|
356 | // |
---|
357 | // These function exist for convenience only and because it is |
---|
358 | // more beautiful to write 'degree( f )' than 'f.degree()'. |
---|
359 | // |
---|
360 | //}}} |
---|
361 | inline CanonicalForm |
---|
362 | lc ( const CanonicalForm & f ) { return f.lc(); } |
---|
363 | |
---|
364 | inline CanonicalForm |
---|
365 | Lc ( const CanonicalForm & f ) { return f.Lc(); } |
---|
366 | |
---|
367 | inline CanonicalForm |
---|
368 | LC ( const CanonicalForm & f ) { return f.LC(); } |
---|
369 | |
---|
370 | inline CanonicalForm |
---|
371 | LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); } |
---|
372 | |
---|
373 | inline int |
---|
374 | degree ( const CanonicalForm & f ) { return f.degree(); } |
---|
375 | |
---|
376 | inline int |
---|
377 | degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); } |
---|
378 | |
---|
379 | inline int |
---|
380 | taildegree ( const CanonicalForm & f ) { return f.taildegree(); } |
---|
381 | |
---|
382 | inline CanonicalForm |
---|
383 | tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); } |
---|
384 | |
---|
385 | inline int |
---|
386 | level ( const CanonicalForm & f ) { return f.level(); } |
---|
387 | |
---|
388 | inline CanonicalForm |
---|
389 | mvar ( const CanonicalForm & f ) { return f.mvar(); } |
---|
390 | |
---|
391 | inline CanonicalForm |
---|
392 | num ( const CanonicalForm & f ) { return f.num(); } |
---|
393 | |
---|
394 | inline CanonicalForm |
---|
395 | den ( const CanonicalForm & f ) { return f.den(); } |
---|
396 | |
---|
397 | inline CanonicalForm |
---|
398 | deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); } |
---|
399 | |
---|
400 | inline CanonicalForm |
---|
401 | sqrt ( const CanonicalForm & a ) { return a.sqrt(); } |
---|
402 | |
---|
403 | inline int |
---|
404 | ilog2 ( const CanonicalForm & a ) { return a.ilog2(); } |
---|
405 | |
---|
406 | inline CanonicalForm |
---|
407 | mapinto ( const CanonicalForm & f ) { return f.mapinto(); } |
---|
408 | //}}} |
---|
409 | |
---|
410 | //{{{ inline functions |
---|
411 | inline CanonicalForm |
---|
412 | head ( const CanonicalForm & f ) |
---|
413 | { |
---|
414 | if ( f.level() > 0 ) |
---|
415 | return power( f.mvar(), f.degree() ) * f.LC(); |
---|
416 | else |
---|
417 | return f; |
---|
418 | } |
---|
419 | |
---|
420 | inline CanonicalForm |
---|
421 | abs ( const CanonicalForm & f ) |
---|
422 | { |
---|
423 | if ( f < 0 ) |
---|
424 | return -f; |
---|
425 | else |
---|
426 | return f; |
---|
427 | } |
---|
428 | |
---|
429 | inline int |
---|
430 | headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); } |
---|
431 | //}}} |
---|
432 | |
---|
433 | //{{{ other function declarations |
---|
434 | void setCharacteristic( int c ); // -> Fp && Q |
---|
435 | void setCharacteristic( int c, int n ); // -> PrimePower |
---|
436 | void setCharacteristic( int c, int n, char name ); // -> GF(q) |
---|
437 | |
---|
438 | int getCharacteristic(); |
---|
439 | int getGFDegree(); |
---|
440 | CanonicalForm getGFGenerator(); |
---|
441 | |
---|
442 | void On( int ); |
---|
443 | void Off( int ); |
---|
444 | bool isOn( int ); |
---|
445 | //}}} |
---|
446 | |
---|
447 | //{{{ type definitions |
---|
448 | typedef Factor<CanonicalForm> CFFactor; |
---|
449 | typedef List<CFFactor> CFFList; |
---|
450 | typedef ListIterator<CFFactor> CFFListIterator; |
---|
451 | typedef List<CanonicalForm> CFList; |
---|
452 | typedef ListIterator<CanonicalForm> CFListIterator; |
---|
453 | typedef Array<CanonicalForm> CFArray; |
---|
454 | typedef Matrix<CanonicalForm> CFMatrix; |
---|
455 | //}}} |
---|
456 | |
---|
457 | |
---|
458 | /* stuff included from ../factory/cf_binom.h */ |
---|
459 | |
---|
460 | |
---|
461 | CanonicalForm binomialpower ( const Variable&, const CanonicalForm&, int ); |
---|
462 | |
---|
463 | |
---|
464 | /* stuff included from ../factory/cf_algorithm.h */ |
---|
465 | |
---|
466 | |
---|
467 | //{{{ function declarations from cf_algorithm.cc |
---|
468 | CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
469 | |
---|
470 | CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
471 | |
---|
472 | void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x ); |
---|
473 | |
---|
474 | CanonicalForm common_den ( const CanonicalForm & f ); |
---|
475 | //}}} |
---|
476 | |
---|
477 | //{{{ function declarations from cf_chinese.cc |
---|
478 | void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2, const CanonicalForm & q2, CanonicalForm & xnew, CanonicalForm & qnew ); |
---|
479 | |
---|
480 | void chineseRemainder ( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew ); |
---|
481 | //}}} |
---|
482 | |
---|
483 | //{{{ function declarations from cf_factor.cc |
---|
484 | CFFList factorize ( const CanonicalForm & f, bool issqrfree = false ); |
---|
485 | |
---|
486 | CFFList factorize ( const CanonicalForm & f, const Variable & alpha ); |
---|
487 | |
---|
488 | CFFList sqrFree ( const CanonicalForm & f, bool sort = false ); |
---|
489 | |
---|
490 | bool isSqrFree ( const CanonicalForm & f ); |
---|
491 | //}}} |
---|
492 | |
---|
493 | //{{{ function declarations from cf_linsys.cc |
---|
494 | bool linearSystemSolve ( CFMatrix & M ); |
---|
495 | |
---|
496 | CanonicalForm determinant ( const CFMatrix & M, int n ); |
---|
497 | //}}} |
---|
498 | |
---|
499 | //{{{ function declarations from cf_resultant.cc |
---|
500 | CFArray subResChain ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
501 | |
---|
502 | CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
503 | //}}} |
---|
504 | |
---|
505 | |
---|
506 | /* stuff included from ../factory/cf_eval.h */ |
---|
507 | |
---|
508 | |
---|
509 | class Evaluation |
---|
510 | { |
---|
511 | protected: |
---|
512 | CFArray values; |
---|
513 | public: |
---|
514 | Evaluation() : values() {} |
---|
515 | Evaluation( int min, int max ) : values( min, max ) {} |
---|
516 | Evaluation( const Evaluation & e ) : values( e.values ) {} |
---|
517 | virtual ~Evaluation() {} |
---|
518 | Evaluation& operator= ( const Evaluation & e ); |
---|
519 | int min() const { return values.min(); } |
---|
520 | int max() const { return values.max(); } |
---|
521 | CanonicalForm operator[] ( int i ) const { return values[i]; } |
---|
522 | CanonicalForm operator[] ( const Variable & v ) const { return operator[](v.level()); } |
---|
523 | CanonicalForm operator() ( const CanonicalForm& f ) const; |
---|
524 | CanonicalForm operator() ( const CanonicalForm & f, int i, int j ) const; |
---|
525 | virtual void nextpoint(); |
---|
526 | #ifndef NOSTREAMIO |
---|
527 | friend ostream& operator<< ( ostream& s, const Evaluation &e ); |
---|
528 | #endif /* NOSTREAMIO */ |
---|
529 | }; |
---|
530 | |
---|
531 | |
---|
532 | /* stuff included from ../factory/cf_generator.h */ |
---|
533 | |
---|
534 | |
---|
535 | class CFGenerator |
---|
536 | { |
---|
537 | public: |
---|
538 | CFGenerator() {} |
---|
539 | virtual ~CFGenerator() {} |
---|
540 | virtual bool hasItems() const { return false; } |
---|
541 | virtual void reset() {}; |
---|
542 | virtual CanonicalForm item() const { return 0; } |
---|
543 | virtual void next() {}; |
---|
544 | }; |
---|
545 | |
---|
546 | class FFGenerator : public CFGenerator |
---|
547 | { |
---|
548 | private: |
---|
549 | int current; |
---|
550 | public: |
---|
551 | FFGenerator() : current(0) {} |
---|
552 | ~FFGenerator() {} |
---|
553 | bool hasItems() const; |
---|
554 | void reset() { current = 0; } |
---|
555 | CanonicalForm item() const; |
---|
556 | void next(); |
---|
557 | void operator++ () { next(); } |
---|
558 | void operator++ ( int ) { next(); } |
---|
559 | }; |
---|
560 | |
---|
561 | class GFGenerator : public CFGenerator |
---|
562 | { |
---|
563 | private: |
---|
564 | int current; |
---|
565 | public: |
---|
566 | GFGenerator(); |
---|
567 | ~GFGenerator() {} |
---|
568 | bool hasItems() const; |
---|
569 | void reset(); |
---|
570 | CanonicalForm item() const; |
---|
571 | void next(); |
---|
572 | void operator++ () { next(); } |
---|
573 | void operator++ ( int ) { next(); } |
---|
574 | }; |
---|
575 | |
---|
576 | class AlgExtGenerator : public CFGenerator |
---|
577 | { |
---|
578 | private: |
---|
579 | Variable algext; |
---|
580 | CFGenerator **gens; |
---|
581 | int n; |
---|
582 | bool nomoreitems; |
---|
583 | AlgExtGenerator(); |
---|
584 | AlgExtGenerator( const AlgExtGenerator & ); |
---|
585 | AlgExtGenerator& operator= ( const AlgExtGenerator & ); |
---|
586 | public: |
---|
587 | AlgExtGenerator( const Variable & a ); |
---|
588 | ~AlgExtGenerator(); |
---|
589 | |
---|
590 | bool hasItems() const { return ! nomoreitems; } |
---|
591 | void reset(); |
---|
592 | CanonicalForm item() const; |
---|
593 | void next(); |
---|
594 | void operator++ () { next(); } |
---|
595 | void operator++ ( int ) { next(); } |
---|
596 | }; |
---|
597 | |
---|
598 | class CFGenFactory |
---|
599 | { |
---|
600 | public: |
---|
601 | static CFGenerator* generate(); |
---|
602 | }; |
---|
603 | |
---|
604 | |
---|
605 | /* stuff included from ../factory/cf_iter.h */ |
---|
606 | |
---|
607 | |
---|
608 | class term; |
---|
609 | typedef term * termList; |
---|
610 | |
---|
611 | class CFIterator { |
---|
612 | private: |
---|
613 | CanonicalForm data; |
---|
614 | termList cursor; |
---|
615 | bool ispoly, hasterms; |
---|
616 | public: |
---|
617 | CFIterator (); |
---|
618 | CFIterator ( const CFIterator& ); |
---|
619 | CFIterator ( const CanonicalForm& ); |
---|
620 | CFIterator ( const CanonicalForm&, const Variable& ); |
---|
621 | |
---|
622 | ~CFIterator (); |
---|
623 | |
---|
624 | CFIterator& operator= ( const CFIterator& ); |
---|
625 | CFIterator& operator= ( const CanonicalForm& ); |
---|
626 | |
---|
627 | CFIterator& operator++ (); |
---|
628 | CFIterator& operator++ ( int ); |
---|
629 | int hasTerms () const; |
---|
630 | CanonicalForm coeff () const; |
---|
631 | int exp () const; |
---|
632 | }; |
---|
633 | |
---|
634 | |
---|
635 | /* stuff included from ../factory/cf_random.h */ |
---|
636 | |
---|
637 | |
---|
638 | class CFRandom { |
---|
639 | public: |
---|
640 | virtual ~CFRandom() {} |
---|
641 | virtual CanonicalForm generate() const { return 0; } |
---|
642 | virtual CFRandom * clone() const { return new CFRandom(); } |
---|
643 | }; |
---|
644 | |
---|
645 | class GFRandom : public CFRandom |
---|
646 | { |
---|
647 | public: |
---|
648 | GFRandom() {}; |
---|
649 | ~GFRandom() {} |
---|
650 | CanonicalForm generate() const; |
---|
651 | CFRandom * clone() const; |
---|
652 | }; |
---|
653 | |
---|
654 | class FFRandom : public CFRandom |
---|
655 | { |
---|
656 | public: |
---|
657 | FFRandom() {} |
---|
658 | ~FFRandom() {} |
---|
659 | CanonicalForm generate() const; |
---|
660 | CFRandom * clone() const; |
---|
661 | }; |
---|
662 | |
---|
663 | class IntRandom : public CFRandom |
---|
664 | { |
---|
665 | private: |
---|
666 | int max; |
---|
667 | public: |
---|
668 | IntRandom(); |
---|
669 | IntRandom( int m ); |
---|
670 | ~IntRandom(); |
---|
671 | CanonicalForm generate() const; |
---|
672 | CFRandom * clone() const; |
---|
673 | }; |
---|
674 | |
---|
675 | class AlgExtRandomF : public CFRandom { |
---|
676 | private: |
---|
677 | Variable algext; |
---|
678 | CFRandom * gen; |
---|
679 | int n; |
---|
680 | AlgExtRandomF(); |
---|
681 | AlgExtRandomF( const AlgExtRandomF & ); |
---|
682 | AlgExtRandomF( const Variable & v, CFRandom * g, int nn ); |
---|
683 | AlgExtRandomF& operator= ( const AlgExtRandomF & ); |
---|
684 | public: |
---|
685 | AlgExtRandomF( const Variable & v ); |
---|
686 | AlgExtRandomF( const Variable & v1, const Variable & v2 ); |
---|
687 | ~AlgExtRandomF(); |
---|
688 | CanonicalForm generate() const; |
---|
689 | CFRandom * clone() const; |
---|
690 | }; |
---|
691 | |
---|
692 | class CFRandomFactory { |
---|
693 | public: |
---|
694 | static CFRandom * generate(); |
---|
695 | }; |
---|
696 | |
---|
697 | int factoryrandom( int n ); |
---|
698 | |
---|
699 | void factoryseed( int s ); |
---|
700 | |
---|
701 | |
---|
702 | /* stuff included from ../factory/cf_irred.h */ |
---|
703 | |
---|
704 | |
---|
705 | CanonicalForm find_irreducible ( int deg, CFRandom & gen, const Variable & x ); |
---|
706 | |
---|
707 | |
---|
708 | /* stuff included from ../factory/fac_util.h */ |
---|
709 | |
---|
710 | |
---|
711 | class modpk |
---|
712 | { |
---|
713 | private: |
---|
714 | CanonicalForm pk; |
---|
715 | CanonicalForm pkhalf; |
---|
716 | int p; |
---|
717 | int k; |
---|
718 | public: |
---|
719 | modpk(); |
---|
720 | modpk( int q, int l ); |
---|
721 | modpk( const modpk & m ); |
---|
722 | modpk& operator= ( const modpk& m ); |
---|
723 | ~modpk() {} |
---|
724 | int getp() const { return p; } |
---|
725 | int getk() const { return k; } |
---|
726 | CanonicalForm inverse( const CanonicalForm & f, bool symmetric = true ) const; |
---|
727 | CanonicalForm getpk() const { return pk; } |
---|
728 | CanonicalForm operator() ( const CanonicalForm & f, bool symmetric = true ) const; |
---|
729 | }; |
---|
730 | |
---|
731 | |
---|
732 | CanonicalForm replaceLc( const CanonicalForm & f, const CanonicalForm & c ); |
---|
733 | |
---|
734 | CanonicalForm remainder( const CanonicalForm & f, const CanonicalForm & g, const modpk & pk ); |
---|
735 | |
---|
736 | void divremainder( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & quot, CanonicalForm & rem, const modpk & pk ); |
---|
737 | |
---|
738 | CanonicalForm maxCoeff( const CanonicalForm & f ); |
---|
739 | |
---|
740 | bool Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & x ); |
---|
741 | |
---|
742 | /* some special array functions */ |
---|
743 | |
---|
744 | CanonicalForm sum ( const CFArray & a, int f, int l ); |
---|
745 | |
---|
746 | CanonicalForm prod ( const CFArray & a, int f, int l ); |
---|
747 | |
---|
748 | CanonicalForm sum ( const CFArray & a ); |
---|
749 | |
---|
750 | CanonicalForm prod ( const CFArray & a ); |
---|
751 | |
---|
752 | CanonicalForm crossprod ( const CFArray & a, const CFArray & b ); |
---|
753 | |
---|
754 | |
---|
755 | /* stuff included from ../factory/cf_map.h */ |
---|
756 | |
---|
757 | |
---|
758 | //{{{ class MapPair |
---|
759 | //{{{ docu |
---|
760 | // |
---|
761 | // class MapPair - stores one mapping pair (Variable -> CanonicalForm). |
---|
762 | // |
---|
763 | // This class is only used to store such pairs. It has no |
---|
764 | // methods to transform a CanonicalForm as the class CFMap has. |
---|
765 | // |
---|
766 | // V, S: the pair (V -> S) |
---|
767 | // |
---|
768 | //}}} |
---|
769 | //{{{ inline method docu |
---|
770 | // |
---|
771 | // Variable var () const |
---|
772 | // CanonicalForm subst () const |
---|
773 | // |
---|
774 | // var(), subst() - selectors, return V and P, resp. |
---|
775 | // |
---|
776 | //}}} |
---|
777 | class MapPair |
---|
778 | { |
---|
779 | private: |
---|
780 | Variable V; |
---|
781 | CanonicalForm S; |
---|
782 | public: |
---|
783 | MapPair ( const Variable & v, const CanonicalForm & s ) : V(v), S(s) {} |
---|
784 | MapPair () : V(), S(1) {} |
---|
785 | MapPair ( const MapPair & p ) : V(p.V), S(p.S) {} |
---|
786 | ~MapPair () {} |
---|
787 | MapPair & operator = ( const MapPair & p ); |
---|
788 | Variable var () const { return V; } |
---|
789 | CanonicalForm subst () const { return S; } |
---|
790 | #ifndef NOSTREAMIO |
---|
791 | friend ostream & operator << ( ostream & s, const MapPair & p ); |
---|
792 | #endif /* NOSTREAMIO */ |
---|
793 | }; |
---|
794 | //}}} |
---|
795 | |
---|
796 | typedef List<MapPair> MPList; |
---|
797 | typedef ListIterator<MapPair> MPListIterator; |
---|
798 | |
---|
799 | //{{{ class CFMap |
---|
800 | //{{{ docu |
---|
801 | // |
---|
802 | // class CFMap - class to map canonical forms. |
---|
803 | // |
---|
804 | // Use an object of class CFMap to insert 'values' into canonical |
---|
805 | // form. Such a mapping is defined by a list of MapPairs (V -> S) |
---|
806 | // describing which canonical form S to insert for variable V. |
---|
807 | // Hereby, the substituted canonical forms are not subject to |
---|
808 | // further substitutions. |
---|
809 | // |
---|
810 | // P: list of MapPairs, sorted by level in descending order |
---|
811 | // |
---|
812 | //}}} |
---|
813 | class CFMap |
---|
814 | { |
---|
815 | private: |
---|
816 | MPList P; |
---|
817 | public: |
---|
818 | CFMap () {} |
---|
819 | CFMap ( const CanonicalForm & s ) : P( MapPair( Variable(), s ) ) {} |
---|
820 | CFMap ( const Variable & v ) : P( MapPair( v, 1 ) ) {} |
---|
821 | CFMap ( const Variable & v, const CanonicalForm & s ) : P( MapPair( v, s ) ) {} |
---|
822 | ~CFMap () {} |
---|
823 | CFMap ( const CFList & L ); |
---|
824 | CFMap ( const CFMap & m ) : P( m.P ) {} |
---|
825 | CFMap & operator = ( const CFMap & m ); |
---|
826 | void newpair ( const Variable & v, const CanonicalForm & s ); |
---|
827 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
828 | #ifndef NOSTREAMIO |
---|
829 | friend ostream & operator << ( ostream & s, const CFMap & m ); |
---|
830 | #endif /* NOSTREAMIO */ |
---|
831 | }; |
---|
832 | //}}} |
---|
833 | |
---|
834 | CanonicalForm compress ( const CanonicalForm & f, CFMap & m ); |
---|
835 | void compress ( const CFArray & a, CFMap & M, CFMap & N ); |
---|
836 | void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N ); |
---|
837 | |
---|
838 | |
---|
839 | /* stuff included from ../factory/cf_reval.h */ |
---|
840 | |
---|
841 | |
---|
842 | class REvaluation : public Evaluation |
---|
843 | { |
---|
844 | private: |
---|
845 | CFRandom * gen; |
---|
846 | public: |
---|
847 | REvaluation() : Evaluation(), gen(0) {} |
---|
848 | REvaluation( int min, int max, const CFRandom & sample ) : Evaluation( min, max ), gen( sample.clone() ) {} |
---|
849 | REvaluation( const REvaluation & e ); |
---|
850 | ~REvaluation(); |
---|
851 | REvaluation& operator= ( const REvaluation & e ); |
---|
852 | void nextpoint(); |
---|
853 | }; |
---|
854 | |
---|
855 | |
---|
856 | #ifdef SINGULAR |
---|
857 | |
---|
858 | /* stuff included from ../factory/gfops.h */ |
---|
859 | |
---|
860 | |
---|
861 | int gf_gf2ff ( int a ); |
---|
862 | |
---|
863 | bool gf_isff ( int a ); |
---|
864 | |
---|
865 | |
---|
866 | /* stuff included from ../factory/singext.h */ |
---|
867 | |
---|
868 | |
---|
869 | MP_INT gmp_numerator ( const CanonicalForm & f ); |
---|
870 | |
---|
871 | MP_INT gmp_denominator ( const CanonicalForm & f ); |
---|
872 | |
---|
873 | CanonicalForm make_cf ( const MP_INT & n ); |
---|
874 | |
---|
875 | CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d, bool normalize ); |
---|
876 | |
---|
877 | |
---|
878 | #endif /* SINGULAR */ |
---|
879 | |
---|
880 | #endif /* ! INCL_FACTORY_H */ |
---|