1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | #ifndef INCL_CF_MAP_H |
---|
4 | #define INCL_CF_MAP_H |
---|
5 | |
---|
6 | //{{{ docu |
---|
7 | // |
---|
8 | // cf_map.h - header to cf_map.cc. |
---|
9 | // |
---|
10 | //}}} |
---|
11 | |
---|
12 | // #include "config.h" |
---|
13 | |
---|
14 | #ifndef NOSTREAMIO |
---|
15 | #ifdef HAVE_IOSTREAM |
---|
16 | #include <iostream> |
---|
17 | #define OSTREAM std::ostream |
---|
18 | #elif defined(HAVE_IOSTREAM_H) |
---|
19 | #include <iostream.h> |
---|
20 | #define OSTREAM ostream |
---|
21 | #endif |
---|
22 | #endif /* NOSTREAMIO */ |
---|
23 | |
---|
24 | #include "variable.h" |
---|
25 | #include "canonicalform.h" |
---|
26 | #include <factory/templates/ftmpl_list.h> |
---|
27 | |
---|
28 | /*BEGINPUBLIC*/ |
---|
29 | |
---|
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 | // |
---|
43 | // Variable var () const |
---|
44 | // CanonicalForm subst () const |
---|
45 | // |
---|
46 | // var(), subst() - selectors, return V and P, resp. |
---|
47 | // |
---|
48 | //}}} |
---|
49 | class MapPair |
---|
50 | { |
---|
51 | private: |
---|
52 | Variable V; |
---|
53 | CanonicalForm S; |
---|
54 | public: |
---|
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; } |
---|
62 | #ifndef NOSTREAMIO |
---|
63 | void print( OSTREAM&) const; |
---|
64 | friend OSTREAM & operator << ( OSTREAM & s, const MapPair & p ); |
---|
65 | #endif /* NOSTREAMIO */ |
---|
66 | }; |
---|
67 | //}}} |
---|
68 | |
---|
69 | typedef List<MapPair> MPList; |
---|
70 | typedef ListIterator<MapPair> MPListIterator; |
---|
71 | |
---|
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) |
---|
79 | // describing which canonical form S to insert for variable V. |
---|
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 | //}}} |
---|
86 | class CFMap |
---|
87 | { |
---|
88 | private: |
---|
89 | MPList P; |
---|
90 | public: |
---|
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 ) {} |
---|
98 | CFMap & operator = ( const CFMap & m ); |
---|
99 | void newpair ( const Variable & v, const CanonicalForm & s ); |
---|
100 | CanonicalForm operator () ( const CanonicalForm & f ) const; |
---|
101 | #ifndef NOSTREAMIO |
---|
102 | friend OSTREAM & operator << ( OSTREAM & s, const CFMap & m ); |
---|
103 | #endif /* NOSTREAMIO */ |
---|
104 | }; |
---|
105 | //}}} |
---|
106 | |
---|
107 | CanonicalForm compress ( const CanonicalForm & f, CFMap & m ); |
---|
108 | void compress ( const CFArray & a, CFMap & M, CFMap & N ); |
---|
109 | void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N ); |
---|
110 | |
---|
111 | /*ENDPUBLIC*/ |
---|
112 | |
---|
113 | #endif /* ! INCL_CF_MAP_H */ |
---|