source: git/factory/winnt/factory.h @ 49f1f45

spielwiese
Last change on this file since 49f1f45 was 49f1f45, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: EZGCD for char p git-svn-id: file:///usr/local/Singular/svn/trunk@10429 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 27.3 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.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
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_SPARSEMOD = 7;
109const int SW_USE_NTL=8;
110const int SW_USE_NTL_GCD_0=9;
111const int SW_USE_NTL_GCD_P=10;
112const int SW_USE_NTL_SORT=11;
113const int SW_USE_CHINREM_GCD=12;
114const int SW_USE_GCD_P=13;
115//}}}
116
117
118/* stuff included from ./variable.h */
119
120
121class CanonicalForm;
122
123class Variable
124{
125private:
126    int _level;
127    Variable( int l, bool flag );
128public:
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};
174Variable rootOf( const CanonicalForm &, char name = '@' );
175
176inline int level( const Variable & v ) { return v.level(); }
177inline char name( const Variable & v ) { return v.name(); }
178
179CanonicalForm getMipo( const Variable & alpha, const Variable & x );
180
181char getDefaultVarName();
182char getDefaultExtName();
183
184int 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
196class InternalCF;
197
198inline 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
205int initCanonicalForm( void );
206
207static int cf_is_initialized_now = initCanonicalForm();
208
209//{{{ class CanonicalForm
210class CanonicalForm
211{
212private:
213    InternalCF *value;
214public:
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
328CF_INLINE CanonicalForm
329operator + ( const CanonicalForm&, const CanonicalForm& );
330
331CF_NO_INLINE CanonicalForm
332operator - ( const CanonicalForm&, const CanonicalForm& );
333
334CF_INLINE CanonicalForm
335operator * ( const CanonicalForm&, const CanonicalForm& );
336
337CF_NO_INLINE CanonicalForm
338operator / ( const CanonicalForm&, const CanonicalForm& );
339
340CF_NO_INLINE CanonicalForm
341operator % ( const CanonicalForm&, const CanonicalForm& );
342
343CF_NO_INLINE CanonicalForm
344div ( const CanonicalForm&, const CanonicalForm& );
345
346CF_NO_INLINE CanonicalForm
347mod ( const CanonicalForm&, const CanonicalForm& );
348
349
350//{{{ function declarations from canonicalform.cc
351CanonicalForm blcm ( const CanonicalForm & f, const CanonicalForm & g );
352
353CanonicalForm power ( const CanonicalForm & f, int n );
354
355CanonicalForm power ( const Variable & v, int n );
356//}}}
357
358//{{{ function declarations from cf_gcd.cc
359CanonicalForm gcd ( const CanonicalForm&, const CanonicalForm& );
360
361CanonicalForm extgcd ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
362
363CanonicalForm lcm ( const CanonicalForm&, const CanonicalForm& );
364
365CanonicalForm pp ( const CanonicalForm& );
366
367CanonicalForm content ( const CanonicalForm& );
368
369CanonicalForm content ( const CanonicalForm&, const Variable& );
370
371CanonicalForm icontent ( const CanonicalForm & f );
372
373CanonicalForm vcontent ( const CanonicalForm & f, const Variable & x );
374//}}}
375
376//{{{ function declarations from cf_ops.cc
377CanonicalForm swapvar ( const CanonicalForm &, const Variable &, const Variable & );
378
379CanonicalForm replacevar ( const CanonicalForm &, const Variable &, const Variable & );
380
381int getNumVars( const CanonicalForm & f );
382
383CanonicalForm getVars( const CanonicalForm & f );
384
385CanonicalForm apply ( const CanonicalForm & f, void (*mf)( CanonicalForm &, int & ) );
386
387CanonicalForm mapdomain ( const CanonicalForm & f, CanonicalForm (*mf)( const CanonicalForm & ) );
388
389int * degrees ( const CanonicalForm & f, int * degs = 0 );
390
391int totaldegree ( const CanonicalForm & f );
392
393int totaldegree ( const CanonicalForm & f, const Variable & v1, const Variable & v2 );
394
395int size ( const CanonicalForm & f, const Variable & v );
396
397int 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//}}}
409inline CanonicalForm
410lc ( const CanonicalForm & f ) { return f.lc(); }
411
412inline CanonicalForm
413Lc ( const CanonicalForm & f ) { return f.Lc(); }
414
415inline CanonicalForm
416LC ( const CanonicalForm & f ) { return f.LC(); }
417
418inline CanonicalForm
419LC ( const CanonicalForm & f, const Variable & v ) { return f.LC( v ); }
420
421inline int
422degree ( const CanonicalForm & f ) { return f.degree(); }
423
424inline int
425degree ( const CanonicalForm & f, const Variable & v ) { return f.degree( v ); }
426
427inline int
428taildegree ( const CanonicalForm & f ) { return f.taildegree(); }
429
430inline CanonicalForm
431tailcoeff ( const CanonicalForm & f ) { return f.tailcoeff(); }
432
433inline int
434level ( const CanonicalForm & f ) { return f.level(); }
435
436inline Variable
437mvar ( const CanonicalForm & f ) { return f.mvar(); }
438
439inline CanonicalForm
440num ( const CanonicalForm & f ) { return f.num(); }
441
442inline CanonicalForm
443den ( const CanonicalForm & f ) { return f.den(); }
444
445inline int
446sign ( const CanonicalForm & a ) { return a.sign(); }
447
448inline CanonicalForm
449deriv ( const CanonicalForm & f, const Variable & x ) { return f.deriv( x ); }
450
451inline CanonicalForm
452sqrt ( const CanonicalForm & a ) { return a.sqrt(); }
453
454inline int
455ilog2 ( const CanonicalForm & a ) { return a.ilog2(); }
456
457inline CanonicalForm
458mapinto ( const CanonicalForm & f ) { return f.mapinto(); }
459//}}}
460
461//{{{ inline functions
462inline CanonicalForm
463head ( 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
471inline int
472headdegree ( const CanonicalForm & f ) { return totaldegree( head( f ) ); }
473
474
475//}}}
476
477//{{{ other function declarations
478void setCharacteristic( int c ); // -> Fp && Q
479void setCharacteristic( int c, int n ); // -> PrimePower
480void setCharacteristic( int c, int n, char name ); // -> GF(q)
481
482int getCharacteristic();
483int getGFDegree();
484CanonicalForm getGFGenerator();
485
486void On( int );
487void Off( int );
488bool isOn( int );
489//}}}
490
491//{{{ type definitions
492typedef Factor<CanonicalForm> CFFactor;
493typedef List<CFFactor> CFFList;
494typedef ListIterator<CFFactor> CFFListIterator;
495typedef List<CanonicalForm> CFList;
496typedef ListIterator<CanonicalForm> CFListIterator;
497typedef Array<CanonicalForm> CFArray;
498typedef Matrix<CanonicalForm> CFMatrix;
499//}}}
500
501
502/* stuff included from ./cf_binom.h */
503
504
505CanonicalForm binomialpower ( const Variable&, const CanonicalForm&, int );
506
507
508/* stuff included from ./cf_algorithm.h */
509
510
511//{{{ function declarations from cf_algorithm.cc
512CanonicalForm psr ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x );
513
514CanonicalForm psq ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x );
515
516void psqr ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & q, CanonicalForm & r, const Variable & x );
517
518CanonicalForm bCommonDen ( const CanonicalForm & f );
519
520bool fdivides ( const CanonicalForm & f, const CanonicalForm & g );
521
522CanonicalForm maxNorm ( const CanonicalForm & f );
523
524CanonicalForm euclideanNorm ( const CanonicalForm & f );
525//}}}
526
527//{{{ function declarations from cf_chinese.cc
528void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2, const CanonicalForm & q2, CanonicalForm & xnew, CanonicalForm & qnew );
529
530void chineseRemainder ( const CFArray & x, const CFArray & q, CanonicalForm & xnew, CanonicalForm & qnew );
531
532CanonicalForm Farey ( const CanonicalForm & f, const CanonicalForm & q );
533//}}}
534
535//{{{ function declarations from cf_factor.cc
536bool isPurePoly(const CanonicalForm & f);
537
538bool isPurePoly_m(const CanonicalForm & f);
539
540CFFList factorize ( const CanonicalForm & f, bool issqrfree = false );
541
542CFFList factorize ( const CanonicalForm & f, const Variable & alpha );
543
544CFFList sqrFree ( const CanonicalForm & f, bool sort = false );
545
546bool isSqrFree ( const CanonicalForm & f );
547
548CanonicalForm homogenize( const CanonicalForm & f, const Variable & x);
549CanonicalForm homogenize( const CanonicalForm & f, const Variable & x,
550                                const Variable & v1, const Variable & v2);
551Variable get_max_degree_Variable(const CanonicalForm & f);
552CFList get_Terms( const CanonicalForm & f );
553void getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result );
554
555
556//}}}
557
558//{{{ function declarations from cf_linsys.cc
559bool linearSystemSolve ( CFMatrix & M );
560
561CanonicalForm determinant ( const CFMatrix & M, int n );
562//}}}
563
564//{{{ function declarations from cf_resultant.cc
565CFArray subResChain ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x );
566
567CanonicalForm 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//}}}
588inline CanonicalForm
589abs ( 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
604class Evaluation
605{
606protected:
607    CFArray values;
608public:
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
630class CFGenerator
631{
632public:
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
641class FFGenerator : public CFGenerator
642{
643private:
644    int current;
645public:
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
656class GFGenerator : public CFGenerator
657{
658private:
659    int current;
660public:
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
671class AlgExtGenerator //??? : public CFGenerator
672{
673private:
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 & );
682public:
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
694class CFGenFactory
695{
696public:
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
710class term;
711typedef term * termList;
712
713class CFIterator {
714private:
715    CanonicalForm data;
716    termList cursor;
717    bool ispoly, hasterms;
718public:
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
740class CFRandom {
741public:
742    virtual ~CFRandom() {}
743    virtual CanonicalForm generate() const { return 0; }
744    virtual CFRandom * clone() const { return new CFRandom(); }
745};
746
747class GFRandom : public CFRandom
748{
749public:
750    GFRandom() {};
751    ~GFRandom() {}
752    CanonicalForm generate() const;
753    CFRandom * clone() const;
754};
755
756class FFRandom : public CFRandom
757{
758public:
759    FFRandom() {}
760    ~FFRandom() {}
761    CanonicalForm generate() const;
762    CFRandom * clone() const;
763};
764
765class IntRandom : public CFRandom
766{
767private:
768    int max;
769public:
770    IntRandom();
771    IntRandom( int m );
772    ~IntRandom();
773    CanonicalForm generate() const;
774    CFRandom * clone() const;
775};
776
777class AlgExtRandomF : public CFRandom {
778private:
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 & );
786public:
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
794class CFRandomFactory {
795public:
796    static CFRandom * generate();
797};
798
799int factoryrandom( int n );
800
801void factoryseed( int s );
802
803
804/* stuff included from ./cf_irred.h */
805
806
807CanonicalForm find_irreducible ( int deg, CFRandom & gen, const Variable & x );
808
809
810/* stuff included from ./fac_util.h */
811
812
813class modpk
814{
815private:
816    CanonicalForm pk;
817    CanonicalForm pkhalf;
818    int p;
819    int k;
820public:
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
834CanonicalForm replaceLc( const CanonicalForm & f, const CanonicalForm & c );
835
836CanonicalForm remainder( const CanonicalForm & f, const CanonicalForm & g, const modpk & pk );
837
838void divremainder( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & quot, CanonicalForm & rem, const modpk & pk );
839
840bool 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
844CanonicalForm sum ( const CFArray & a, int f, int l );
845
846CanonicalForm prod ( const CFArray & a, int f, int l );
847
848CanonicalForm sum ( const CFArray & a );
849
850CanonicalForm prod ( const CFArray & a );
851
852CanonicalForm 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//}}}
877class MapPair
878{
879private:
880    Variable V;
881    CanonicalForm S;
882public:
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
897typedef List<MapPair> MPList;
898typedef 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//}}}
914class CFMap
915{
916private:
917  MPList P;
918public:
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
935CanonicalForm compress ( const CanonicalForm & f, CFMap & m );
936void compress ( const CFArray & a, CFMap & M, CFMap & N );
937void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N );
938
939
940/* stuff included from ./cf_reval.h */
941
942
943class REvaluation : public Evaluation
944{
945private:
946    CFRandom * gen;
947public:
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
962int gf_gf2ff ( int a );
963
964bool gf_isff ( int a );
965
966
967/* stuff included from ./singext.h */
968
969
970MP_INT gmp_numerator ( const CanonicalForm & f );
971
972MP_INT gmp_denominator ( const CanonicalForm & f );
973
974int gf_value (const CanonicalForm & f );
975
976CanonicalForm make_cf ( const MP_INT & n );
977
978CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d, bool normalize );
979
980CanonicalForm 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
989CFFList AbsFactorize( const CanonicalForm  & a );
990
991class 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 */
Note: See TracBrowser for help on using the repository browser.