1 | /* winnt/factory.h automatically generated by makeheader from factory.template */ |
---|
2 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
3 | /* $Id: factory.h,v 1.6 2007-11-20 10:08:03 Singular 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 | #ifdef HAVE_IOSTREAM |
---|
29 | #include <iostream> |
---|
30 | #define OSTREAM std::ostream |
---|
31 | #define ISTREAM std::istream |
---|
32 | #elif defined(HAVE_IOSTREAM_H) |
---|
33 | #include <iostream.h> |
---|
34 | #define OSTREAM ostream |
---|
35 | #define ISTREAM istream |
---|
36 | #endif |
---|
37 | #endif /* ! NOSTREAMIO */ |
---|
38 | |
---|
39 | #ifdef SINGULAR |
---|
40 | #include "cf_gmp.h" |
---|
41 | #else |
---|
42 | #include <gmp.h> |
---|
43 | #endif /* SINGULAR */ |
---|
44 | |
---|
45 | #ifdef macintosh |
---|
46 | #include <:templates:ftmpl_array.h> |
---|
47 | #include <:templates:ftmpl_factor.h> |
---|
48 | #include <:templates:ftmpl_list.h> |
---|
49 | #include <:templates:ftmpl_matrix.h> |
---|
50 | #else |
---|
51 | #include <templates/ftmpl_array.h> |
---|
52 | #include <templates/ftmpl_factor.h> |
---|
53 | #include <templates/ftmpl_list.h> |
---|
54 | #include <templates/ftmpl_matrix.h> |
---|
55 | #endif |
---|
56 | |
---|
57 | /* stuff included from ./cf_globals.h */ |
---|
58 | |
---|
59 | |
---|
60 | extern const char factoryVersion[]; |
---|
61 | extern const char factoryConfiguration[]; |
---|
62 | |
---|
63 | |
---|
64 | /* stuff included from ./cf_primes.h */ |
---|
65 | |
---|
66 | |
---|
67 | int cf_getPrime( int i ); |
---|
68 | |
---|
69 | int cf_getNumPrimes(); |
---|
70 | |
---|
71 | int cf_getSmallPrime( int i ); |
---|
72 | |
---|
73 | int cf_getNumSmallPrimes(); |
---|
74 | |
---|
75 | int cf_getBigPrime( int i ); |
---|
76 | |
---|
77 | int cf_getNumBigPrimes(); |
---|
78 | |
---|
79 | |
---|
80 | /* stuff included from ./cf_defs.h */ |
---|
81 | |
---|
82 | |
---|
83 | #define LEVELBASE -1000000 |
---|
84 | #define LEVELTRANS -500000 |
---|
85 | #define LEVELQUOT 1000000 |
---|
86 | #define LEVELEXPR 1000001 |
---|
87 | |
---|
88 | #define UndefinedDomain 32000 |
---|
89 | #define PrimePowerDomain 5 |
---|
90 | #define GaloisFieldDomain 4 |
---|
91 | #define FiniteFieldDomain 3 |
---|
92 | #define RationalDomain 2 |
---|
93 | #define IntegerDomain 1 |
---|
94 | |
---|
95 | //{{{ constants |
---|
96 | //{{{ docu |
---|
97 | // |
---|
98 | // - factory switches. |
---|
99 | // |
---|
100 | //}}} |
---|
101 | const int SW_RATIONAL = 0; |
---|
102 | const int SW_QUOTIENT = 1; |
---|
103 | const int SW_SYMMETRIC_FF = 2; |
---|
104 | const int SW_BERLEKAMP = 3; |
---|
105 | const int SW_FAC_USE_BIG_PRIMES = 4; |
---|
106 | const int SW_FAC_QUADRATICLIFT = 5; |
---|
107 | const int SW_USE_EZGCD = 6; |
---|
108 | const int SW_USE_SPARSEMOD = 7; |
---|
109 | const int SW_USE_NTL=8; |
---|
110 | const int SW_USE_NTL_GCD_0=9; |
---|
111 | const int SW_USE_NTL_GCD_P=10; |
---|
112 | const int SW_USE_NTL_SORT=11; |
---|
113 | const int SW_USE_CHINREM_GCD=12; |
---|
114 | const int SW_USE_GCD_P=13; |
---|
115 | //}}} |
---|
116 | |
---|
117 | |
---|
118 | /* stuff included from ./variable.h */ |
---|
119 | |
---|
120 | |
---|
121 | class CanonicalForm; |
---|
122 | |
---|
123 | class Variable |
---|
124 | { |
---|
125 | private: |
---|
126 | int _level; |
---|
127 | Variable( int l, bool flag ); |
---|
128 | public: |
---|
129 | Variable() : _level(LEVELBASE) {} |
---|
130 | Variable( int l ); |
---|
131 | Variable( char name ); |
---|
132 | Variable( int l, char name ); |
---|
133 | Variable( const Variable & v ) : _level(v._level) {} |
---|
134 | ~Variable() {}; |
---|
135 | Variable& operator= ( const Variable & v ) |
---|
136 | { |
---|
137 | _level = v._level; |
---|
138 | return *this; |
---|
139 | } |
---|
140 | int level() const { return _level; } |
---|
141 | char name() const; |
---|
142 | static Variable highest() { return Variable( LEVELQUOT-1 ); } |
---|
143 | Variable next() const { return Variable( _level+1 ); } |
---|
144 | friend bool operator == ( const Variable & lhs, const Variable & rhs ) |
---|
145 | { |
---|
146 | return lhs._level == rhs._level; |
---|
147 | } |
---|
148 | friend bool operator != ( const Variable & lhs, const Variable & rhs ) |
---|
149 | { |
---|
150 | return lhs._level != rhs._level; |
---|
151 | } |
---|
152 | friend bool operator > ( const Variable & lhs, const Variable & rhs ) |
---|
153 | { |
---|
154 | return lhs._level > rhs._level; |
---|
155 | } |
---|
156 | friend bool operator < ( const Variable & lhs, const Variable & rhs ) |
---|
157 | { |
---|
158 | return lhs._level < rhs._level; |
---|
159 | } |
---|
160 | friend bool operator >= ( const Variable & lhs, const Variable & rhs ) |
---|
161 | { |
---|
162 | return lhs._level >= rhs._level; |
---|
163 | } |
---|
164 | friend bool operator <= ( const Variable & lhs, const Variable & rhs ) |
---|
165 | { |
---|
166 | return lhs._level <= rhs._level; |
---|
167 | } |
---|
168 | #ifndef NOSTREAMIO |
---|
169 | friend OSTREAM & operator << ( OSTREAM & os, const Variable & v ); |
---|
170 | #endif /* NOSTREAMIO */ |
---|
171 | friend void swap_levels(); |
---|
172 | friend Variable rootOf( const CanonicalForm &, char name ); |
---|
173 | }; |
---|
174 | Variable rootOf( const CanonicalForm &, char name = '@' ); |
---|
175 | |
---|
176 | inline int level( const Variable & v ) { return v.level(); } |
---|
177 | inline char name( const Variable & v ) { return v.name(); } |
---|
178 | |
---|
179 | CanonicalForm getMipo( const Variable & alpha, const Variable & x ); |
---|
180 | |
---|
181 | char getDefaultVarName(); |
---|
182 | char getDefaultExtName(); |
---|
183 | |
---|
184 | int ExtensionLevel(); |
---|
185 | |
---|
186 | |
---|
187 | /* stuff included from ./canonicalform.h */ |
---|
188 | |
---|
189 | |
---|
190 | #undef CF_INLINE |
---|
191 | #define CF_INLINE |
---|
192 | #undef CF_NO_INLINE |
---|
193 | #define CF_NO_INLINE |
---|
194 | |
---|
195 | |
---|
196 | class InternalCF; |
---|
197 | |
---|
198 | inline int is_imm ( const InternalCF * const ptr ) |
---|
199 | { |
---|
200 | // returns 0 if ptr is not immediate |
---|
201 | return ( ((int)((long)ptr)) & 3 ); |
---|
202 | } |
---|
203 | |
---|
204 | |
---|
205 | int initCanonicalForm( void ); |
---|
206 | |
---|
207 | static int cf_is_initialized_now = initCanonicalForm(); |
---|
208 | |
---|
209 | //{{{ class CanonicalForm |
---|
210 | class CanonicalForm |
---|
211 | { |
---|
212 | private: |
---|
213 | InternalCF *value; |
---|
214 | public: |
---|
215 | // constructors, destructors, selectors |
---|
216 | CF_INLINE CanonicalForm(); |
---|
217 | CF_INLINE CanonicalForm( const CanonicalForm& ); |
---|
218 | CF_INLINE CanonicalForm( InternalCF* ); |
---|
219 | CF_INLINE CanonicalForm( const int ); |
---|
220 | CF_INLINE CanonicalForm( const Variable & ); |
---|
221 | CF_INLINE CanonicalForm( const Variable &, int ); |
---|
222 | CanonicalForm( const char *, const int base=10 ); // use with caution - does only handle integers !!! |
---|
223 | |
---|
224 | CF_NO_INLINE ~CanonicalForm(); |
---|
225 | |
---|
226 | InternalCF* getval() const; // use with caution !!! |
---|
227 | |
---|
228 | CanonicalForm deepCopy() const; |
---|
229 | |
---|
230 | // predicates |
---|
231 | CF_NO_INLINE bool isOne() const; |
---|
232 | CF_NO_INLINE bool isZero() const; |
---|
233 | inline bool isImm() const { return is_imm( value ); }; |
---|
234 | |
---|
235 | bool inZ() const; |
---|
236 | bool inQ() const; |
---|
237 | bool inFF() const; |
---|
238 | bool inGF() const; |
---|
239 | bool inPP() const; |
---|
240 | bool inBaseDomain() const; |
---|
241 | bool inExtension() const; |
---|
242 | bool inCoeffDomain() const; |
---|
243 | bool inPolyDomain() const; |
---|
244 | bool inQuotDomain() const; |
---|
245 | |
---|
246 | bool isFFinGF() const; |
---|
247 | bool isUnivariate() const; |
---|
248 | bool isHomogeneous() const; |
---|
249 | |
---|
250 | // conversion functions |
---|
251 | int intval() const; |
---|
252 | CanonicalForm mapinto () const; |
---|
253 | |
---|
254 | CanonicalForm lc () const; |
---|
255 | CanonicalForm Lc () const; |
---|
256 | CanonicalForm LC () const; |
---|
257 | CanonicalForm LC ( const Variable & v ) const; |
---|
258 | |
---|
259 | int degree () const; |
---|
260 | int degree ( const Variable & v ) const; |
---|
261 | |
---|
262 | CanonicalForm tailcoeff () const; |
---|
263 | int taildegree () const; |
---|
264 | |
---|
265 | int level () const; |
---|
266 | Variable mvar () const; |
---|
267 | |
---|
268 | CanonicalForm num () const; |
---|
269 | CanonicalForm den () const; |
---|
270 | |
---|
271 | // assignment operators |
---|
272 | CF_NO_INLINE CanonicalForm& operator = ( const CanonicalForm& ); |
---|
273 | CF_NO_INLINE CanonicalForm& operator = ( const int ); |
---|
274 | |
---|
275 | CanonicalForm& operator += ( const CanonicalForm& ); |
---|
276 | CanonicalForm& operator -= ( const CanonicalForm& ); |
---|
277 | CanonicalForm& operator *= ( const CanonicalForm& ); |
---|
278 | CanonicalForm& operator /= ( const CanonicalForm& ); |
---|
279 | CanonicalForm& operator %= ( const CanonicalForm& ); |
---|
280 | CanonicalForm& div ( const CanonicalForm& ); |
---|
281 | CanonicalForm& mod ( const CanonicalForm& ); |
---|
282 | |
---|
283 | // evaluation operators |
---|
284 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
285 | CanonicalForm operator () ( const CanonicalForm & f, const Variable & v ) const; |
---|
286 | |
---|
287 | CanonicalForm operator [] ( int i ) const; |
---|
288 | |
---|
289 | CanonicalForm deriv() const; |
---|
290 | CanonicalForm deriv( const Variable & x ) const; |
---|
291 | |
---|
292 | int sign() const; |
---|
293 | CanonicalForm sqrt() const; |
---|
294 | int ilog2() const; |
---|
295 | |
---|
296 | // comparison operators |
---|
297 | friend bool operator == ( const CanonicalForm&, const CanonicalForm& ); |
---|
298 | friend bool operator != ( const CanonicalForm&, const CanonicalForm& ); |
---|
299 | friend bool operator > ( const CanonicalForm&, const CanonicalForm& ); |
---|
300 | friend bool operator < ( const CanonicalForm&, const CanonicalForm& ); |
---|
301 | |
---|
302 | // arithmetic operators |
---|
303 | friend CF_NO_INLINE CanonicalForm operator - ( const CanonicalForm& ); |
---|
304 | |
---|
305 | friend void divrem ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
306 | friend bool divremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
307 | |
---|
308 | friend CanonicalForm bgcd ( const CanonicalForm &, const CanonicalForm & ); |
---|
309 | friend CanonicalForm bextgcd ( const CanonicalForm &, const CanonicalForm &, CanonicalForm &, CanonicalForm & ); |
---|
310 | |
---|
311 | // input/output |
---|
312 | #ifndef NOSTREAMIO |
---|
313 | void print( OSTREAM&, char * ) const; |
---|
314 | void print( OSTREAM& ) const; |
---|
315 | friend OSTREAM& operator << ( OSTREAM&, const CanonicalForm& ); |
---|
316 | friend ISTREAM& operator >> ( ISTREAM&, CanonicalForm& ); |
---|
317 | #endif /* NOSTREAMIO */ |
---|
318 | |
---|
319 | // obsolete methods |
---|
320 | static CanonicalForm genCoeff( int what, int i = 0 ); |
---|
321 | CanonicalForm genZero() const; |
---|
322 | CanonicalForm genOne() const; |
---|
323 | |
---|
324 | friend class CFIterator; |
---|
325 | }; |
---|
326 | //}}} |
---|
327 | |
---|
328 | CF_INLINE CanonicalForm |
---|
329 | operator + ( const CanonicalForm&, const CanonicalForm& ); |
---|
330 | |
---|
331 | CF_NO_INLINE CanonicalForm |
---|
332 | operator - ( const CanonicalForm&, const CanonicalForm& ); |
---|
333 | |
---|
334 | CF_INLINE CanonicalForm |
---|
335 | operator * ( const CanonicalForm&, const CanonicalForm& ); |
---|
336 | |
---|
337 | CF_NO_INLINE CanonicalForm |
---|
338 | operator / ( const CanonicalForm&, const CanonicalForm& ); |
---|
339 | |
---|
340 | CF_NO_INLINE CanonicalForm |
---|
341 | operator % ( const CanonicalForm&, const CanonicalForm& ); |
---|
342 | |
---|
343 | CF_NO_INLINE CanonicalForm |
---|
344 | div ( const CanonicalForm&, const CanonicalForm& ); |
---|
345 | |
---|
346 | CF_NO_INLINE CanonicalForm |
---|
347 | mod ( const CanonicalForm&, const CanonicalForm& ); |
---|
348 | |
---|
349 | |
---|
350 | //{{{ function declarations from canonicalform.cc |
---|
351 | CanonicalForm blcm ( const CanonicalForm & f, const CanonicalForm & g ); |
---|
352 | |
---|
353 | CanonicalForm power ( const CanonicalForm & f, int n ); |
---|
354 | |
---|
355 | CanonicalForm power ( const Variable & v, int n ); |
---|
356 | //}}} |
---|
357 | |
---|
358 | //{{{ function declarations from cf_gcd.cc |
---|
359 | CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& ); |
---|
360 | |
---|
361 | CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& ); |
---|
362 | |
---|
363 | CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& ); |
---|
364 | |
---|
365 | CanonicalForm pp ( const CanonicalForm& ); |
---|
366 | |
---|
367 | CanonicalForm content ( const CanonicalForm& ); |
---|
368 | |
---|
369 | CanonicalForm content ( const CanonicalForm&, const Variable& ); |
---|
370 | |
---|
371 | CanonicalForm icontent ( const CanonicalForm & f ); |
---|
372 | |
---|
373 | CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x ); |
---|
374 | //}}} |
---|
375 | |
---|
376 | //{{{ function declarations from cf_ops.cc |
---|
377 | CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & ); |
---|
378 | |
---|
379 | CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & ); |
---|
380 | |
---|
381 | int getNumVars( const CanonicalForm & f ); |
---|
382 | |
---|
383 | CanonicalForm getVars( const CanonicalForm & f ); |
---|
384 | |
---|
385 | CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) ); |
---|
386 | |
---|
387 | CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) ); |
---|
388 | |
---|
389 | int * degrees ( const CanonicalForm & f, int * degs = 0 ); |
---|
390 | |
---|
391 | int totaldegree ( const CanonicalForm & f ); |
---|
392 | |
---|
393 | int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 ); |
---|
394 | |
---|
395 | int size ( const CanonicalForm & f, const Variable & v ); |
---|
396 | |
---|
397 | int size ( const CanonicalForm & f ); |
---|
398 | //}}} |
---|
399 | |
---|
400 | //{{{ inline functions corresponding to CanonicalForm methods |
---|
401 | //{{{ docu |
---|
402 | // |
---|
403 | // - inline functions corresponding to CanonicalForm methods. |
---|
404 | // |
---|
405 | // These function exist for convenience only and because it is |
---|
406 | // more beautiful to write 'degree( f )' than 'f.degree()'. |
---|
407 | // |
---|
408 | //}}} |
---|
409 | inline CanonicalForm |
---|
410 | lc ( const CanonicalForm & f ) { return f.lc(); } |
---|
411 | |
---|
412 | inline CanonicalForm |
---|
413 | Lc ( const CanonicalForm & f ) { return f.Lc(); } |
---|
414 | |
---|
415 | inline CanonicalForm |
---|
416 | LC ( const CanonicalForm & f ) { return f.LC(); } |
---|
417 | |
---|
418 | inline CanonicalForm |
---|
419 | LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); } |
---|
420 | |
---|
421 | inline int |
---|
422 | degree ( const CanonicalForm & f ) { return f.degree(); } |
---|
423 | |
---|
424 | inline int |
---|
425 | degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); } |
---|
426 | |
---|
427 | inline int |
---|
428 | taildegree ( const CanonicalForm & f ) { return f.taildegree(); } |
---|
429 | |
---|
430 | inline CanonicalForm |
---|
431 | tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); } |
---|
432 | |
---|
433 | inline int |
---|
434 | level ( const CanonicalForm & f ) { return f.level(); } |
---|
435 | |
---|
436 | inline Variable |
---|
437 | mvar ( const CanonicalForm & f ) { return f.mvar(); } |
---|
438 | |
---|
439 | inline CanonicalForm |
---|
440 | num ( const CanonicalForm & f ) { return f.num(); } |
---|
441 | |
---|
442 | inline CanonicalForm |
---|
443 | den ( const CanonicalForm & f ) { return f.den(); } |
---|
444 | |
---|
445 | inline int |
---|
446 | sign ( const CanonicalForm & a ) { return a.sign(); } |
---|
447 | |
---|
448 | inline CanonicalForm |
---|
449 | deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); } |
---|
450 | |
---|
451 | inline CanonicalForm |
---|
452 | sqrt ( const CanonicalForm & a ) { return a.sqrt(); } |
---|
453 | |
---|
454 | inline int |
---|
455 | ilog2 ( const CanonicalForm & a ) { return a.ilog2(); } |
---|
456 | |
---|
457 | inline CanonicalForm |
---|
458 | mapinto ( const CanonicalForm & f ) { return f.mapinto(); } |
---|
459 | //}}} |
---|
460 | |
---|
461 | //{{{ inline functions |
---|
462 | inline CanonicalForm |
---|
463 | head ( const CanonicalForm & f ) |
---|
464 | { |
---|
465 | if ( f.level() > 0 ) |
---|
466 | return power( f.mvar(), f.degree() ) * f.LC(); |
---|
467 | else |
---|
468 | return f; |
---|
469 | } |
---|
470 | |
---|
471 | inline int |
---|
472 | headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); } |
---|
473 | |
---|
474 | |
---|
475 | //}}} |
---|
476 | |
---|
477 | //{{{ other function declarations |
---|
478 | void setCharacteristic( int c ); // -> Fp && Q |
---|
479 | void setCharacteristic( int c, int n ); // -> PrimePower |
---|
480 | void setCharacteristic( int c, int n, char name ); // -> GF(q) |
---|
481 | |
---|
482 | int getCharacteristic(); |
---|
483 | int getGFDegree(); |
---|
484 | CanonicalForm getGFGenerator(); |
---|
485 | |
---|
486 | void On( int ); |
---|
487 | void Off( int ); |
---|
488 | bool isOn( int ); |
---|
489 | //}}} |
---|
490 | |
---|
491 | //{{{ type definitions |
---|
492 | typedef Factor<CanonicalForm> CFFactor; |
---|
493 | typedef List<CFFactor> CFFList; |
---|
494 | typedef ListIterator<CFFactor> CFFListIterator; |
---|
495 | typedef List<CanonicalForm> CFList; |
---|
496 | typedef ListIterator<CanonicalForm> CFListIterator; |
---|
497 | typedef Array<CanonicalForm> CFArray; |
---|
498 | typedef Matrix<CanonicalForm> CFMatrix; |
---|
499 | //}}} |
---|
500 | |
---|
501 | |
---|
502 | /* stuff included from ./cf_binom.h */ |
---|
503 | |
---|
504 | |
---|
505 | CanonicalForm binomialpower ( const Variable&, const CanonicalForm&, int ); |
---|
506 | |
---|
507 | |
---|
508 | /* stuff included from ./cf_algorithm.h */ |
---|
509 | |
---|
510 | |
---|
511 | //{{{ function declarations from cf_algorithm.cc |
---|
512 | CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
513 | |
---|
514 | CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
515 | |
---|
516 | void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x ); |
---|
517 | |
---|
518 | CanonicalForm bCommonDen ( const CanonicalForm & f ); |
---|
519 | |
---|
520 | bool fdivides ( const CanonicalForm & f, const CanonicalForm & g ); |
---|
521 | |
---|
522 | CanonicalForm maxNorm ( const CanonicalForm & f ); |
---|
523 | |
---|
524 | CanonicalForm euclideanNorm ( const CanonicalForm & f ); |
---|
525 | //}}} |
---|
526 | |
---|
527 | //{{{ function declarations from cf_chinese.cc |
---|
528 | void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2, const CanonicalForm & q2, CanonicalForm & xnew, CanonicalForm & qnew ); |
---|
529 | |
---|
530 | void chineseRemainder ( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew ); |
---|
531 | |
---|
532 | CanonicalForm Farey ( const CanonicalForm & f, const CanonicalForm & q ); |
---|
533 | //}}} |
---|
534 | |
---|
535 | //{{{ function declarations from cf_factor.cc |
---|
536 | bool isPurePoly(const CanonicalForm & f); |
---|
537 | |
---|
538 | bool isPurePoly_m(const CanonicalForm & f); |
---|
539 | |
---|
540 | CFFList factorize ( const CanonicalForm & f, bool issqrfree = false ); |
---|
541 | |
---|
542 | CFFList factorize ( const CanonicalForm & f, const Variable & alpha ); |
---|
543 | |
---|
544 | CFFList sqrFree ( const CanonicalForm & f, bool sort = false ); |
---|
545 | |
---|
546 | bool isSqrFree ( const CanonicalForm & f ); |
---|
547 | |
---|
548 | CanonicalForm homogenize( const CanonicalForm & f, const Variable & x); |
---|
549 | CanonicalForm homogenize( const CanonicalForm & f, const Variable & x, |
---|
550 | const Variable & v1, const Variable & v2); |
---|
551 | Variable get_max_degree_Variable(const CanonicalForm & f); |
---|
552 | CFList get_Terms( const CanonicalForm & f ); |
---|
553 | void getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result ); |
---|
554 | |
---|
555 | |
---|
556 | //}}} |
---|
557 | |
---|
558 | //{{{ function declarations from cf_linsys.cc |
---|
559 | bool linearSystemSolve ( CFMatrix & M ); |
---|
560 | |
---|
561 | CanonicalForm determinant ( const CFMatrix & M, int n ); |
---|
562 | //}}} |
---|
563 | |
---|
564 | //{{{ function declarations from cf_resultant.cc |
---|
565 | CFArray subResChain ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
566 | |
---|
567 | CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ); |
---|
568 | //}}} |
---|
569 | |
---|
570 | //{{{ inline CanonicalForm abs ( const CanonicalForm & f ) |
---|
571 | //{{{ docu |
---|
572 | // |
---|
573 | // abs() - return absolute value of `f'. |
---|
574 | // |
---|
575 | // The absolute value is defined in terms of the function |
---|
576 | // `sign()'. If it reports negative sign for `f' than -`f' is |
---|
577 | // returned, otherwise `f'. |
---|
578 | // |
---|
579 | // This behaviour is most useful for integers and rationals. But |
---|
580 | // it may be used to sign-normalize the leading coefficient of |
---|
581 | // arbitrary polynomials, too. |
---|
582 | // |
---|
583 | // Type info: |
---|
584 | // ---------- |
---|
585 | // f: CurrentPP |
---|
586 | // |
---|
587 | //}}} |
---|
588 | inline CanonicalForm |
---|
589 | abs ( const CanonicalForm & f ) |
---|
590 | { |
---|
591 | // it is not only more general to use `sign()' instead of a |
---|
592 | // direct comparison `f < 0', it is faster, too |
---|
593 | if ( sign( f ) < 0 ) |
---|
594 | return -f; |
---|
595 | else |
---|
596 | return f; |
---|
597 | } |
---|
598 | //}}} |
---|
599 | |
---|
600 | |
---|
601 | /* stuff included from ./cf_eval.h */ |
---|
602 | |
---|
603 | |
---|
604 | class Evaluation |
---|
605 | { |
---|
606 | protected: |
---|
607 | CFArray values; |
---|
608 | public: |
---|
609 | Evaluation() : values() {} |
---|
610 | Evaluation( int min, int max ) : values( min, max ) {} |
---|
611 | Evaluation( const Evaluation & e ) : values( e.values ) {} |
---|
612 | virtual ~Evaluation() {} |
---|
613 | Evaluation& operator= ( const Evaluation & e ); |
---|
614 | int min() const { return values.min(); } |
---|
615 | int max() const { return values.max(); } |
---|
616 | CanonicalForm operator[] ( int i ) const { return values[i]; } |
---|
617 | CanonicalForm operator[] ( const Variable & v ) const { return operator[](v.level()); } |
---|
618 | CanonicalForm operator() ( const CanonicalForm& f ) const; |
---|
619 | CanonicalForm operator() ( const CanonicalForm & f, int i, int j ) const; |
---|
620 | virtual void nextpoint(); |
---|
621 | #ifndef NOSTREAMIO |
---|
622 | friend OSTREAM& operator<< ( OSTREAM& s, const Evaluation &e ); |
---|
623 | #endif /* NOSTREAMIO */ |
---|
624 | }; |
---|
625 | |
---|
626 | |
---|
627 | /* stuff included from ./cf_generator.h */ |
---|
628 | |
---|
629 | |
---|
630 | class CFGenerator |
---|
631 | { |
---|
632 | public: |
---|
633 | CFGenerator() {} |
---|
634 | virtual ~CFGenerator() {} |
---|
635 | virtual bool hasItems() const { return false; } |
---|
636 | virtual void reset() {}; |
---|
637 | virtual CanonicalForm item() const { return 0; } |
---|
638 | virtual void next() {}; |
---|
639 | }; |
---|
640 | |
---|
641 | class FFGenerator : public CFGenerator |
---|
642 | { |
---|
643 | private: |
---|
644 | int current; |
---|
645 | public: |
---|
646 | FFGenerator() : current(0) {} |
---|
647 | ~FFGenerator() {} |
---|
648 | bool hasItems() const; |
---|
649 | void reset() { current = 0; } |
---|
650 | CanonicalForm item() const; |
---|
651 | void next(); |
---|
652 | void operator++ () { next(); } |
---|
653 | void operator++ ( int ) { next(); } |
---|
654 | }; |
---|
655 | |
---|
656 | class GFGenerator : public CFGenerator |
---|
657 | { |
---|
658 | private: |
---|
659 | int current; |
---|
660 | public: |
---|
661 | GFGenerator(); |
---|
662 | ~GFGenerator() {} |
---|
663 | bool hasItems() const; |
---|
664 | void reset(); |
---|
665 | CanonicalForm item() const; |
---|
666 | void next(); |
---|
667 | void operator++ () { next(); } |
---|
668 | void operator++ ( int ) { next(); } |
---|
669 | }; |
---|
670 | |
---|
671 | class AlgExtGenerator //??? : public CFGenerator |
---|
672 | { |
---|
673 | private: |
---|
674 | Variable algext; |
---|
675 | FFGenerator **gensf; |
---|
676 | GFGenerator **gensg; |
---|
677 | int n; |
---|
678 | bool nomoreitems; |
---|
679 | AlgExtGenerator(); |
---|
680 | AlgExtGenerator( const AlgExtGenerator & ); |
---|
681 | AlgExtGenerator& operator= ( const AlgExtGenerator & ); |
---|
682 | public: |
---|
683 | AlgExtGenerator( const Variable & a ); |
---|
684 | ~AlgExtGenerator(); |
---|
685 | |
---|
686 | bool hasItems() const { return ! nomoreitems; } |
---|
687 | void reset(); |
---|
688 | CanonicalForm item() const; |
---|
689 | void next(); |
---|
690 | void operator++ () { next(); } |
---|
691 | void operator++ ( int ) { next(); } |
---|
692 | }; |
---|
693 | |
---|
694 | class CFGenFactory |
---|
695 | { |
---|
696 | public: |
---|
697 | static CFGenerator* generate(); |
---|
698 | }; |
---|
699 | |
---|
700 | |
---|
701 | /* stuff included from ./cf_iter.h */ |
---|
702 | |
---|
703 | |
---|
704 | #undef CF_INLINE |
---|
705 | #define CF_INLINE |
---|
706 | #undef CF_NO_INLINE |
---|
707 | #define CF_NO_INLINE |
---|
708 | |
---|
709 | |
---|
710 | class term; |
---|
711 | typedef term * termList; |
---|
712 | |
---|
713 | class CFIterator { |
---|
714 | private: |
---|
715 | CanonicalForm data; |
---|
716 | termList cursor; |
---|
717 | bool ispoly, hasterms; |
---|
718 | public: |
---|
719 | CFIterator (); |
---|
720 | CFIterator ( const CFIterator& ); |
---|
721 | CFIterator ( const CanonicalForm& ); |
---|
722 | CFIterator ( const CanonicalForm&, const Variable& ); |
---|
723 | |
---|
724 | ~CFIterator (); |
---|
725 | |
---|
726 | CFIterator& operator= ( const CFIterator& ); |
---|
727 | CFIterator& operator= ( const CanonicalForm& ); |
---|
728 | |
---|
729 | CF_NO_INLINE CFIterator& operator++ (); |
---|
730 | CF_NO_INLINE CFIterator& operator++ ( int ); |
---|
731 | CF_NO_INLINE int hasTerms () const; |
---|
732 | CF_NO_INLINE CanonicalForm coeff () const; |
---|
733 | CF_NO_INLINE int exp () const; |
---|
734 | }; |
---|
735 | |
---|
736 | |
---|
737 | /* stuff included from ./cf_random.h */ |
---|
738 | |
---|
739 | |
---|
740 | class CFRandom { |
---|
741 | public: |
---|
742 | virtual ~CFRandom() {} |
---|
743 | virtual CanonicalForm generate() const { return 0; } |
---|
744 | virtual CFRandom * clone() const { return new CFRandom(); } |
---|
745 | }; |
---|
746 | |
---|
747 | class GFRandom : public CFRandom |
---|
748 | { |
---|
749 | public: |
---|
750 | GFRandom() {}; |
---|
751 | ~GFRandom() {} |
---|
752 | CanonicalForm generate() const; |
---|
753 | CFRandom * clone() const; |
---|
754 | }; |
---|
755 | |
---|
756 | class FFRandom : public CFRandom |
---|
757 | { |
---|
758 | public: |
---|
759 | FFRandom() {} |
---|
760 | ~FFRandom() {} |
---|
761 | CanonicalForm generate() const; |
---|
762 | CFRandom * clone() const; |
---|
763 | }; |
---|
764 | |
---|
765 | class IntRandom : public CFRandom |
---|
766 | { |
---|
767 | private: |
---|
768 | int max; |
---|
769 | public: |
---|
770 | IntRandom(); |
---|
771 | IntRandom( int m ); |
---|
772 | ~IntRandom(); |
---|
773 | CanonicalForm generate() const; |
---|
774 | CFRandom * clone() const; |
---|
775 | }; |
---|
776 | |
---|
777 | class AlgExtRandomF : public CFRandom { |
---|
778 | private: |
---|
779 | Variable algext; |
---|
780 | CFRandom * gen; |
---|
781 | int n; |
---|
782 | AlgExtRandomF(); |
---|
783 | AlgExtRandomF( const AlgExtRandomF & ); |
---|
784 | AlgExtRandomF( const Variable & v, CFRandom * g, int nn ); |
---|
785 | AlgExtRandomF& operator= ( const AlgExtRandomF & ); |
---|
786 | public: |
---|
787 | AlgExtRandomF( const Variable & v ); |
---|
788 | AlgExtRandomF( const Variable & v1, const Variable & v2 ); |
---|
789 | ~AlgExtRandomF(); |
---|
790 | CanonicalForm generate() const; |
---|
791 | CFRandom * clone() const; |
---|
792 | }; |
---|
793 | |
---|
794 | class CFRandomFactory { |
---|
795 | public: |
---|
796 | static CFRandom * generate(); |
---|
797 | }; |
---|
798 | |
---|
799 | int factoryrandom( int n ); |
---|
800 | |
---|
801 | void factoryseed( int s ); |
---|
802 | |
---|
803 | |
---|
804 | /* stuff included from ./cf_irred.h */ |
---|
805 | |
---|
806 | |
---|
807 | CanonicalForm find_irreducible ( int deg, CFRandom & gen, const Variable & x ); |
---|
808 | |
---|
809 | |
---|
810 | /* stuff included from ./fac_util.h */ |
---|
811 | |
---|
812 | |
---|
813 | class modpk |
---|
814 | { |
---|
815 | private: |
---|
816 | CanonicalForm pk; |
---|
817 | CanonicalForm pkhalf; |
---|
818 | int p; |
---|
819 | int k; |
---|
820 | public: |
---|
821 | modpk(); |
---|
822 | modpk( int q, int l ); |
---|
823 | modpk( const modpk & m ); |
---|
824 | modpk& operator= ( const modpk& m ); |
---|
825 | ~modpk() {} |
---|
826 | int getp() const { return p; } |
---|
827 | int getk() const { return k; } |
---|
828 | CanonicalForm inverse( const CanonicalForm & f, bool symmetric = true ) const; |
---|
829 | CanonicalForm getpk() const { return pk; } |
---|
830 | CanonicalForm operator() ( const CanonicalForm & f, bool symmetric = true ) const; |
---|
831 | }; |
---|
832 | |
---|
833 | |
---|
834 | CanonicalForm replaceLc( const CanonicalForm & f, const CanonicalForm & c ); |
---|
835 | |
---|
836 | CanonicalForm remainder( const CanonicalForm & f, const CanonicalForm & g, const modpk & pk ); |
---|
837 | |
---|
838 | void divremainder( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & quot, CanonicalForm & rem, const modpk & pk ); |
---|
839 | |
---|
840 | bool Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & x ); |
---|
841 | |
---|
842 | /* some special array functions */ |
---|
843 | |
---|
844 | CanonicalForm sum ( const CFArray & a, int f, int l ); |
---|
845 | |
---|
846 | CanonicalForm prod ( const CFArray & a, int f, int l ); |
---|
847 | |
---|
848 | CanonicalForm sum ( const CFArray & a ); |
---|
849 | |
---|
850 | CanonicalForm prod ( const CFArray & a ); |
---|
851 | |
---|
852 | CanonicalForm crossprod ( const CFArray & a, const CFArray & b ); |
---|
853 | |
---|
854 | |
---|
855 | /* stuff included from ./cf_map.h */ |
---|
856 | |
---|
857 | |
---|
858 | //{{{ class MapPair |
---|
859 | //{{{ docu |
---|
860 | // |
---|
861 | // class MapPair - stores one mapping pair (Variable -> CanonicalForm). |
---|
862 | // |
---|
863 | // This class is only used to store such pairs. It has no |
---|
864 | // methods to transform a CanonicalForm as the class CFMap has. |
---|
865 | // |
---|
866 | // V, S: the pair (V -> S) |
---|
867 | // |
---|
868 | //}}} |
---|
869 | //{{{ inline method docu |
---|
870 | // |
---|
871 | // Variable var () const |
---|
872 | // CanonicalForm subst () const |
---|
873 | // |
---|
874 | // var(), subst() - selectors, return V and P, resp. |
---|
875 | // |
---|
876 | //}}} |
---|
877 | class MapPair |
---|
878 | { |
---|
879 | private: |
---|
880 | Variable V; |
---|
881 | CanonicalForm S; |
---|
882 | public: |
---|
883 | MapPair ( const Variable & v, const CanonicalForm & s ) : V(v), S(s) {} |
---|
884 | MapPair () : V(), S(1) {} |
---|
885 | MapPair ( const MapPair & p ) : V(p.V), S(p.S) {} |
---|
886 | ~MapPair () {} |
---|
887 | MapPair & operator = ( const MapPair & p ); |
---|
888 | Variable var () const { return V; } |
---|
889 | CanonicalForm subst () const { return S; } |
---|
890 | #ifndef NOSTREAMIO |
---|
891 | void print( OSTREAM&) const; |
---|
892 | friend OSTREAM & operator << ( OSTREAM & s, const MapPair & p ); |
---|
893 | #endif /* NOSTREAMIO */ |
---|
894 | }; |
---|
895 | //}}} |
---|
896 | |
---|
897 | typedef List<MapPair> MPList; |
---|
898 | typedef ListIterator<MapPair> MPListIterator; |
---|
899 | |
---|
900 | //{{{ class CFMap |
---|
901 | //{{{ docu |
---|
902 | // |
---|
903 | // class CFMap - class to map canonical forms. |
---|
904 | // |
---|
905 | // Use an object of class CFMap to insert 'values' into canonical |
---|
906 | // form. Such a mapping is defined by a list of MapPairs (V -> S) |
---|
907 | // describing which canonical form S to insert for variable V. |
---|
908 | // Hereby, the substituted canonical forms are not subject to |
---|
909 | // further substitutions. |
---|
910 | // |
---|
911 | // P: list of MapPairs, sorted by level in descending order |
---|
912 | // |
---|
913 | //}}} |
---|
914 | class CFMap |
---|
915 | { |
---|
916 | private: |
---|
917 | MPList P; |
---|
918 | public: |
---|
919 | CFMap () {} |
---|
920 | CFMap ( const CanonicalForm & s ) : P( MapPair( Variable(), s ) ) {} |
---|
921 | CFMap ( const Variable & v ) : P( MapPair( v, 1 ) ) {} |
---|
922 | CFMap ( const Variable & v, const CanonicalForm & s ) : P( MapPair( v, s ) ) {} |
---|
923 | ~CFMap () {} |
---|
924 | CFMap ( const CFList & L ); |
---|
925 | CFMap ( const CFMap & m ) : P( m.P ) {} |
---|
926 | CFMap & operator = ( const CFMap & m ); |
---|
927 | void newpair ( const Variable & v, const CanonicalForm & s ); |
---|
928 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
929 | #ifndef NOSTREAMIO |
---|
930 | friend OSTREAM & operator << ( OSTREAM & s, const CFMap & m ); |
---|
931 | #endif /* NOSTREAMIO */ |
---|
932 | }; |
---|
933 | //}}} |
---|
934 | |
---|
935 | CanonicalForm compress ( const CanonicalForm & f, CFMap & m ); |
---|
936 | void compress ( const CFArray & a, CFMap & M, CFMap & N ); |
---|
937 | void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N ); |
---|
938 | |
---|
939 | |
---|
940 | /* stuff included from ./cf_reval.h */ |
---|
941 | |
---|
942 | |
---|
943 | class REvaluation : public Evaluation |
---|
944 | { |
---|
945 | private: |
---|
946 | CFRandom * gen; |
---|
947 | public: |
---|
948 | REvaluation() : Evaluation(), gen(0) {} |
---|
949 | REvaluation( int min, int max, const CFRandom & sample ) : Evaluation( min, max ), gen( sample.clone() ) {} |
---|
950 | REvaluation( const REvaluation & e ); |
---|
951 | ~REvaluation(); |
---|
952 | REvaluation& operator= ( const REvaluation & e ); |
---|
953 | void nextpoint(); |
---|
954 | }; |
---|
955 | |
---|
956 | |
---|
957 | #ifdef SINGULAR |
---|
958 | |
---|
959 | /* stuff included from ./gfops.h */ |
---|
960 | |
---|
961 | |
---|
962 | int gf_gf2ff ( int a ); |
---|
963 | |
---|
964 | bool gf_isff ( int a ); |
---|
965 | |
---|
966 | |
---|
967 | /* stuff included from ./singext.h */ |
---|
968 | |
---|
969 | |
---|
970 | MP_INT gmp_numerator ( const CanonicalForm & f ); |
---|
971 | |
---|
972 | MP_INT gmp_denominator ( const CanonicalForm & f ); |
---|
973 | |
---|
974 | int gf_value (const CanonicalForm & f ); |
---|
975 | |
---|
976 | CanonicalForm make_cf ( const MP_INT & n ); |
---|
977 | |
---|
978 | CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d, bool normalize ); |
---|
979 | |
---|
980 | CanonicalForm make_cf_from_gf ( const int z ); |
---|
981 | |
---|
982 | |
---|
983 | #endif /* SINGULAR */ |
---|
984 | |
---|
985 | #ifdef HAVE_BIFAC |
---|
986 | /* stuff included from ./bifac.h */ |
---|
987 | |
---|
988 | |
---|
989 | CFFList AbsFactorize( const CanonicalForm & a ); |
---|
990 | |
---|
991 | class BIFAC |
---|
992 | { |
---|
993 | //////////////////////////////////////////////////////////////// |
---|
994 | public: |
---|
995 | //////////////////////////////////////////////////////////////// |
---|
996 | |
---|
997 | // === KONST-/ DESTRUKTOREN ==== |
---|
998 | BIFAC ( void ); // Konstruktor |
---|
999 | virtual ~BIFAC( void ); // DESTRUKTOR |
---|
1000 | |
---|
1001 | // === Funktionen ======= |
---|
1002 | void bifac(CanonicalForm f, bool absolute=true); |
---|
1003 | CFFList getFactors( void ){ return gl_RL; }; |
---|
1004 | |
---|
1005 | |
---|
1006 | //////////////////////////////////////////////////////////////// |
---|
1007 | private: |
---|
1008 | //////////////////////////////////////////////////////////////// |
---|
1009 | |
---|
1010 | // === Funktionen ======= |
---|
1011 | void passedTime(); |
---|
1012 | void biGanzMachen( CanonicalForm & f ); |
---|
1013 | void biNormieren( CanonicalForm & f ) ; |
---|
1014 | void convertResult( CanonicalForm & f, int ch, int sw); |
---|
1015 | int findCharacteristic(CanonicalForm f); |
---|
1016 | // void matrix_drucken( CFMatrix M ); |
---|
1017 | long int anz_terme( CanonicalForm & f ); |
---|
1018 | |
---|
1019 | CFList matrix2basis(CFMatrix A, int dim, int m, int n, CanonicalForm f); |
---|
1020 | CFList basisOfG(CanonicalForm f); |
---|
1021 | CFMatrix createA (CFList G, CanonicalForm f); |
---|
1022 | CanonicalForm create_g (CFList G); |
---|
1023 | CFList createRg (CFList G, CanonicalForm f); |
---|
1024 | CFList createEg (CFList G, CanonicalForm f); |
---|
1025 | CFList createEgUni (CFList G, CanonicalForm f); |
---|
1026 | |
---|
1027 | void unifac(CanonicalForm f, int grad); |
---|
1028 | CanonicalForm RationalFactor (CanonicalForm phi, CanonicalForm f, \ |
---|
1029 | CanonicalForm fx, CanonicalForm g); |
---|
1030 | void RationalFactorizationOnly (CFFList Phis, CanonicalForm f, CanonicalForm g); |
---|
1031 | CFList getAbsoluteFactors (CanonicalForm f1, CanonicalForm phi); |
---|
1032 | void AbsoluteFactorization (CFFList Phis, CanonicalForm f, CanonicalForm g); |
---|
1033 | void bifacSqrFree( CanonicalForm f ); |
---|
1034 | void bifacMain(CanonicalForm f); |
---|
1035 | |
---|
1036 | |
---|
1037 | // === Variable ======= |
---|
1038 | CFFList gl_RL; // where to store the rational factorization |
---|
1039 | CFList gl_AL; // where to store the absolute factorization |
---|
1040 | bool absolute; // Compute an absolute factorization as well? |
---|
1041 | int exponent; // |
---|
1042 | }; |
---|
1043 | |
---|
1044 | #endif /* HAVE_BIFAC */ |
---|
1045 | |
---|
1046 | #endif /* ! INCL_FACTORY_H */ |
---|