[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[341696] | 2 | /* $Id$ */ |
---|
[2dd068] | 3 | |
---|
| 4 | #ifndef INCL_CF_MAP_H |
---|
| 5 | #define INCL_CF_MAP_H |
---|
| 6 | |
---|
[95d5c6] | 7 | //{{{ docu |
---|
| 8 | // |
---|
| 9 | // cf_map.h - header to cf_map.cc. |
---|
| 10 | // |
---|
| 11 | //}}} |
---|
| 12 | |
---|
[e4fe2b] | 13 | // #include "config.h" |
---|
[b973c0] | 14 | |
---|
[997ae52] | 15 | #ifndef NOSTREAMIO |
---|
[1dc616] | 16 | #ifdef HAVE_IOSTREAM |
---|
| 17 | #include <iostream> |
---|
[181148] | 18 | #define OSTREAM std::ostream |
---|
[1dc616] | 19 | #elif defined(HAVE_IOSTREAM_H) |
---|
[2dd068] | 20 | #include <iostream.h> |
---|
[181148] | 21 | #define OSTREAM ostream |
---|
[1dc616] | 22 | #endif |
---|
[997ae52] | 23 | #endif /* NOSTREAMIO */ |
---|
| 24 | |
---|
[2dd068] | 25 | #include "variable.h" |
---|
[95d5c6] | 26 | #include "canonicalform.h" |
---|
[ee668e] | 27 | #include <factory/templates/ftmpl_list.h> |
---|
[2dd068] | 28 | |
---|
| 29 | /*BEGINPUBLIC*/ |
---|
| 30 | |
---|
[95d5c6] | 31 | //{{{ class MapPair |
---|
| 32 | //{{{ docu |
---|
| 33 | // |
---|
| 34 | // class MapPair - stores one mapping pair (Variable -> CanonicalForm). |
---|
| 35 | // |
---|
| 36 | // This class is only used to store such pairs. It has no |
---|
| 37 | // methods to transform a CanonicalForm as the class CFMap has. |
---|
| 38 | // |
---|
| 39 | // V, S: the pair (V -> S) |
---|
| 40 | // |
---|
| 41 | //}}} |
---|
| 42 | //{{{ inline method docu |
---|
| 43 | // |
---|
[f2e972] | 44 | // Variable var () const |
---|
| 45 | // CanonicalForm subst () const |
---|
[95d5c6] | 46 | // |
---|
| 47 | // var(), subst() - selectors, return V and P, resp. |
---|
| 48 | // |
---|
| 49 | //}}} |
---|
[2dd068] | 50 | class MapPair |
---|
| 51 | { |
---|
| 52 | private: |
---|
| 53 | Variable V; |
---|
| 54 | CanonicalForm S; |
---|
| 55 | public: |
---|
[f2e972] | 56 | MapPair ( const Variable & v, const CanonicalForm & s ) : V(v), S(s) {} |
---|
| 57 | MapPair () : V(), S(1) {} |
---|
| 58 | MapPair ( const MapPair & p ) : V(p.V), S(p.S) {} |
---|
| 59 | ~MapPair () {} |
---|
| 60 | MapPair & operator = ( const MapPair & p ); |
---|
| 61 | Variable var () const { return V; } |
---|
| 62 | CanonicalForm subst () const { return S; } |
---|
[997ae52] | 63 | #ifndef NOSTREAMIO |
---|
[181148] | 64 | void print( OSTREAM&) const; |
---|
| 65 | friend OSTREAM & operator << ( OSTREAM & s, const MapPair & p ); |
---|
[997ae52] | 66 | #endif /* NOSTREAMIO */ |
---|
[2dd068] | 67 | }; |
---|
[95d5c6] | 68 | //}}} |
---|
[2dd068] | 69 | |
---|
| 70 | typedef List<MapPair> MPList; |
---|
| 71 | typedef ListIterator<MapPair> MPListIterator; |
---|
| 72 | |
---|
[95d5c6] | 73 | //{{{ class CFMap |
---|
| 74 | //{{{ docu |
---|
| 75 | // |
---|
| 76 | // class CFMap - class to map canonical forms. |
---|
| 77 | // |
---|
| 78 | // Use an object of class CFMap to insert 'values' into canonical |
---|
| 79 | // form. Such a mapping is defined by a list of MapPairs (V -> S) |
---|
[f2e972] | 80 | // describing which canonical form S to insert for variable V. |
---|
[95d5c6] | 81 | // Hereby, the substituted canonical forms are not subject to |
---|
| 82 | // further substitutions. |
---|
| 83 | // |
---|
| 84 | // P: list of MapPairs, sorted by level in descending order |
---|
| 85 | // |
---|
| 86 | //}}} |
---|
[2dd068] | 87 | class CFMap |
---|
| 88 | { |
---|
| 89 | private: |
---|
| 90 | MPList P; |
---|
| 91 | public: |
---|
[f2e972] | 92 | CFMap () {} |
---|
| 93 | CFMap ( const CanonicalForm & s ) : P( MapPair( Variable(), s ) ) {} |
---|
| 94 | CFMap ( const Variable & v ) : P( MapPair( v, 1 ) ) {} |
---|
| 95 | CFMap ( const Variable & v, const CanonicalForm & s ) : P( MapPair( v, s ) ) {} |
---|
| 96 | ~CFMap () {} |
---|
| 97 | CFMap ( const CFList & L ); |
---|
| 98 | CFMap ( const CFMap & m ) : P( m.P ) {} |
---|
[95d5c6] | 99 | CFMap & operator = ( const CFMap & m ); |
---|
[f2e972] | 100 | void newpair ( const Variable & v, const CanonicalForm & s ); |
---|
[95d5c6] | 101 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
[997ae52] | 102 | #ifndef NOSTREAMIO |
---|
[181148] | 103 | friend OSTREAM & operator << ( OSTREAM & s, const CFMap & m ); |
---|
[997ae52] | 104 | #endif /* NOSTREAMIO */ |
---|
[2dd068] | 105 | }; |
---|
[95d5c6] | 106 | //}}} |
---|
[2dd068] | 107 | |
---|
| 108 | CanonicalForm compress ( const CanonicalForm & f, CFMap & m ); |
---|
| 109 | void compress ( const CFArray & a, CFMap & M, CFMap & N ); |
---|
[cc3e5e] | 110 | void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N ); |
---|
[2dd068] | 111 | |
---|
| 112 | /*ENDPUBLIC*/ |
---|
| 113 | |
---|
[493c477] | 114 | #endif /* ! INCL_CF_MAP_H */ |
---|