source: git/factory/cf_map.h @ 8d1432e

spielwiese
Last change on this file since 8d1432e was abddbe, checked in by Martin Lee <martinlee84@…>, 10 years ago
chg: added brief descriptions to some files
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_CF_MAP_H
4#define INCL_CF_MAP_H
5
6/**
7 * @file cf_map.h
8 *
9 * map polynomials
10 *
11**/
12
13// #include "config.h"
14
15#ifndef NOSTREAMIO
16#ifdef HAVE_IOSTREAM
17#include <iostream>
18#define OSTREAM std::ostream
19#elif defined(HAVE_IOSTREAM_H)
20#include <iostream.h>
21#define OSTREAM ostream
22#endif
23#endif /* NOSTREAMIO */
24
25#include "variable.h"
26#include "canonicalform.h"
27#include <factory/templates/ftmpl_list.h>
28
29/*BEGINPUBLIC*/
30
31/** class MapPair
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
42 *
43 * Variable var () const
44 * CanonicalForm subst () const
45 *
46 * var(), subst() - selectors, return V and P, resp.
47 *
48**/
49class MapPair
50{
51private:
52    Variable V;
53    CanonicalForm S;
54public:
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
68typedef List<MapPair> MPList;
69typedef ListIterator<MapPair> MPListIterator;
70
71/** class CFMap
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**/
84class CFMap
85{
86private:
87  MPList P;
88public:
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
104CanonicalForm compress ( const CanonicalForm & f, CFMap & m );
105void compress ( const CFArray & a, CFMap & M, CFMap & N );
106void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N );
107
108/*ENDPUBLIC*/
109
110#endif /* ! INCL_CF_MAP_H */
Note: See TracBrowser for help on using the repository browser.