source: git/factory/winnt/factory.h @ 8d14d67

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