source: git/factory/cf_map.h @ 1dc616

spielwiese
Last change on this file since 1dc616 was 1dc616, checked in by Hans Schönemann <hannes@…>, 18 years ago
*hannes: test for iostream and iostream.h git-svn-id: file:///usr/local/Singular/svn/trunk@9134 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: cf_map.h,v 1.13 2006-05-15 08:17:50 Singular 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#ifdef HAVE_IOSTREAM
17#include <iostream>
18#elif defined(HAVE_IOSTREAM_H)
19#include <iostream.h>
20#endif
21#endif /* NOSTREAMIO */
22
23#include "variable.h"
24#include "canonicalform.h"
25#include "ftmpl_list.h"
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//}}}
48class MapPair
49{
50private:
51    Variable V;
52    CanonicalForm S;
53public:
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    void print( ostream&) const;
63    friend ostream & operator << ( ostream & s, const MapPair & p );
64#endif /* NOSTREAMIO */
65};
66//}}}
67
68typedef List<MapPair> MPList;
69typedef ListIterator<MapPair> MPListIterator;
70
71//{{{ class CFMap
72//{{{ docu
73//
74// class CFMap - class to map canonical forms.
75//
76// Use an object of class CFMap to insert 'values' into canonical
77// form.  Such a mapping is defined by a list of MapPairs (V -> S)
78// describing which canonical form S to insert for variable V.
79// Hereby, the substituted canonical forms are not subject to
80// further substitutions.
81//
82// P: list of MapPairs, sorted by level in descending order
83//
84//}}}
85class CFMap
86{
87private:
88  MPList P;
89public:
90  CFMap () {}
91  CFMap ( const CanonicalForm & s ) : P( MapPair( Variable(), s ) ) {}
92  CFMap ( const Variable & v ) : P( MapPair( v, 1 ) ) {}
93  CFMap ( const Variable & v, const CanonicalForm & s ) : P( MapPair( v, s ) ) {}
94  ~CFMap () {}
95  CFMap ( const CFList & L );
96  CFMap ( const CFMap & m ) : P( m.P ) {}
97  CFMap & operator = ( const CFMap & m );
98  void newpair ( const Variable & v, const CanonicalForm & s );
99  CanonicalForm operator () ( const CanonicalForm & f ) const;
100#ifndef NOSTREAMIO
101  friend ostream & operator << ( ostream & s, const CFMap & m );
102#endif /* NOSTREAMIO */
103};
104//}}}
105
106CanonicalForm compress ( const CanonicalForm & f, CFMap & m );
107void compress ( const CFArray & a, CFMap & M, CFMap & N );
108void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N );
109
110/*ENDPUBLIC*/
111
112#endif /* ! INCL_CF_MAP_H */
Note: See TracBrowser for help on using the repository browser.