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