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