source: git/factory/winnt/factory.h @ e8857b

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