source: git/factory/cf_map.h @ 362fc67

spielwiese
Last change on this file since 362fc67 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[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]49class MapPair
50{
51private:
52    Variable V;
53    CanonicalForm S;
54public:
[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
69typedef List<MapPair> MPList;
70typedef 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]86class CFMap
87{
88private:
89  MPList P;
90public:
[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
107CanonicalForm compress ( const CanonicalForm & f, CFMap & m );
108void compress ( const CFArray & a, CFMap & M, CFMap & N );
[cc3e5e]109void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N );
[2dd068]110
111/*ENDPUBLIC*/
112
[493c477]113#endif /* ! INCL_CF_MAP_H */
Note: See TracBrowser for help on using the repository browser.