Vaucanson  1.4.1
krat.hh
1 // krat.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_HH
19 
20 # include <list>
21 
22 # include <vaucanson/algebra/implementation/series/series.hh>
23 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
24 # include <vaucanson/algebra/implementation/series/rat/dump_visitor.hh>
25 
26 namespace vcsn {
27 
28  namespace algebra {
29 
30  /*------------------.
31  | Series compliance |
32  `------------------*/
33 
34  template<typename Tm, typename Tw>
35  struct series_traits<rat::exp<Tm, Tw> >
36  {
37  typedef Tm monoid_elt_value_t;
38  typedef Tw semiring_elt_value_t;
39  typedef std::list<monoid_elt_value_t> support_t;
40  };
41 
42  template <class Tm, class Tw, class W, class M>
43  struct mute_series_impl<rat::exp<Tm, Tw>, W, M>
44  {
45  typedef rat::exp<M, W> ret;
46  };
47 
48  } // algebra
49 
50  /*---------------------------------------------.
51  | MetaElement<Series<W, M>, rat::exp<Tm, Tw> > |
52  `---------------------------------------------*/
53  template<typename W, typename M, typename Tm, typename Tw>
54  struct MetaElement<algebra::Series<W, M>, rat::exp<Tm, Tw> >
55  : MetaElement<algebra::SeriesBase<algebra::Series<W, M> >,
56  rat::exp<Tm, Tw> >
57  {
58  static const bool dynamic_value = true;
59 
60  void accept(const rat::ConstNodeVisitor<Tm, Tw>& v) const;
61  size_t depth() const;
62  };
63 
64 
65  namespace algebra {
66 
67  template<typename W, typename M, typename Tm, typename Tw>
68  bool op_contains(const algebra::Series<W, M>& s,
69  const rat::exp<Tm, Tw>& m);
70 
71  template<typename W, typename M, typename Tm, typename Tw>
72  bool op_is_finite_app(const algebra::Series<W, M>& s,
73  const rat::exp<Tm, Tw>& m);
74 
75  template <typename W, typename M, typename Tm, typename Tw>
76  Tm op_choose_from_supp(const algebra::Series<W, M>& s,
77  const rat::exp<Tm, Tw>& m);
78 
79  template<typename W, typename M, typename Tm, typename Tw>
80  const rat::exp<Tm, Tw>& identity_value(SELECTOR2(algebra::Series<W, M>),
81  SELECTOR2(rat::exp<Tm, Tw>));
82 
83  template<typename W, typename M, typename Tm, typename Tw>
84  bool show_identity_value(SELECTOR2(algebra::Series<W, M>),
85  SELECTOR2(rat::exp<Tm, Tw>));
86 
87 
88  template<typename W, typename M, typename Tm, typename Tw>
89  const rat::exp<Tm, Tw>& zero_value(SELECTOR2(algebra::Series<W, M>),
90  SELECTOR2(rat::exp<Tm, Tw>));
91 
92 
93  template<typename W, typename M, typename Tm, typename Tw>
94  void op_in_add(const algebra::Series<W, M>& s,
95  rat::exp<Tm, Tw>& dst,
96  const rat::exp<Tm, Tw>& arg);
97 
98  template<typename W, typename M, typename Tm, typename Tw>
99  rat::exp<Tm, Tw> op_mul(const algebra::Series<W, M>& s,
100  const rat::exp<Tm, Tw>& a,
101  const rat::exp<Tm, Tw>& b);
102 
103  template<typename W, typename M, typename Tm, typename Tw>
104  void op_in_mul(const algebra::Series<W, M>& s,
105  rat::exp<Tm, Tw>& dst,
106  const rat::exp<Tm, Tw>& arg);
107 
108  template<typename W, typename M, typename Tm, typename Tw>
109  rat::exp<Tm, Tw> op_mul(const algebra::Series<W, M>& s,
110  const rat::exp<Tm, Tw>& a,
111  const rat::exp<Tm, Tw>& b);
112 
113 
114  /*---------------------.
115  | foreign constructors |
116  `---------------------*/
117 
118  template<typename Tm, typename Tw, typename M, typename W>
119  rat::exp<Tm, Tw> op_convert(SELECTOR2(algebra::Series<M, W>),
120  SELECTOR2(rat::exp<Tm, Tw>),
121  const Tm& m_value);
122 
123  template<typename Tm, typename Tw, typename M, typename W>
124  rat::exp<Tm, Tw> op_convert(SELECTOR2(algebra::Series<M, W>),
125  SELECTOR2(rat::exp<Tm, Tw>),
126  char m_value);
127 
128  template<typename Tm, typename Tw, typename W, typename M, typename oTm>
129  rat::exp<Tm, Tw> op_convert(SELECTOR2(algebra::Series<W, M>),
130  SELECTOR2(rat::exp<Tm, Tw>),
131  SELECTOR(M),
132  const oTm& m_value);
133 
134  template<typename Tm, typename Tw, typename W, typename M, typename oTw>
135  rat::exp<Tm, Tw> op_convert(SELECTOR2(algebra::Series<W, M>),
136  SELECTOR2(rat::exp<Tm, Tw>),
137  SELECTOR(W),
138  const oTw& w_value);
139 
140  template<typename W, typename M, typename Tm, typename Tw, typename oTm>
141  void op_assign(const algebra::Series<W, M>& s,
142  const M& monoid,
143  rat::exp<Tm, Tw>& dst,
144  const oTm& src);
145 
146  template<typename W, typename M, typename Tm, typename Tw, typename oTw>
147  void op_assign(const algebra::Series<W, M>& s,
148  const W& semiring,
149  rat::exp<Tm, Tw>& dst,
150  const oTw& src);
151 
152  /*-----.
153  | star |
154  `-----*/
155 
156  template<typename W, typename M, typename Tm, typename Tw>
157  bool op_starable(const algebra::Series<W, M>& s,
158  const rat::exp<Tm, Tw>& dst);
159 
160  template<typename W, typename M, typename Tm, typename Tw>
161  void op_in_star(const algebra::Series<W, M>& s,
162  rat::exp<Tm, Tw>& dst);
163 
164  template<typename W, typename M, typename Tm, typename Tw>
165  rat::exp<Tm, Tw>
166  op_star(const algebra::Series<W, M>& s,
167  const rat::exp<Tm, Tw>& src);
168 
169  } // algebra
170 
171  /*--------------------------------------.
172  | foreign addition with monoid elements |
173  `--------------------------------------*/
174 
175  template<typename M, typename W, typename oTm, typename Tm, typename Tw>
176  struct op_add_traits<M, algebra::Series<W, M>, oTm, rat::exp<Tm, Tw> >
177  {
178  typedef Element<algebra::Series<W, M>, rat::exp<Tm, Tw> > ret_t;
179  };
180 
181  namespace algebra {
182 
183  template<typename W, typename M, typename Tm, typename Tw, typename oTm>
184  void op_in_add(const algebra::Series<W, M>& s,
185  const M& monoid,
186  rat::exp<Tm, Tw>& dst,
187  const oTm& src);
188 
189  template<typename W, typename M, typename Tm, typename Tw, typename oTm>
190  rat::exp<Tm, Tw> op_add(const algebra::Series<W, M>& s,
191  const M& monoid,
192  const rat::exp<Tm, Tw>& a,
193  const oTm& b);
194 
195  template<typename M, typename W, typename oTm, typename Tm, typename Tw>
196  rat::exp<Tm, Tw> op_add(const M& monoid,
197  const algebra::Series<W, M>& s,
198  const oTm& a,
199  const rat::exp<Tm, Tw>& b);
200 
201  }
202 
203  /*---------------------------------------.
204  | foreign addition with semiring elements |
205  `---------------------------------------*/
206 
207  template<typename W, typename M, typename oTw, typename Tm, typename Tw>
208  struct op_add_traits<W, algebra::Series<W, M>, oTw, rat::exp<Tm, Tw> >
209  {
210  typedef Element<algebra::Series<W, M>, rat::exp<Tm, Tw> > ret_t;
211  };
212 
213  namespace algebra {
214 
215  template<typename W, typename M, typename Tm, typename Tw, typename oTw>
216  void op_in_add(const algebra::Series<W, M>& s,
217  const W& semiring,
218  rat::exp<Tm, Tw>& dst,
219  const oTw& src);
220 
221  template<typename W, typename M, typename Tm, typename Tw, typename oTw>
222  rat::exp<Tm, Tw> op_add(const algebra::Series<W, M>& s,
223  const W& semiring,
224  const rat::exp<Tm, Tw>& a,
225  const oTw& b);
226 
227  template<typename W, typename M, typename oTw, typename Tm, typename Tw>
228  rat::exp<Tm, Tw> op_add(const W& semiring,
229  const algebra::Series<W, M>& s,
230  const oTw& a,
231  const rat::exp<Tm, Tw>& b);
232 
233  }
234 
235  /*-------------------------------------------.
236  | foreign multiplication by semiring elements |
237  `-------------------------------------------*/
238 
239  template<typename W, typename M, typename oTw, typename Tm, typename Tw>
240  struct op_mul_traits<W, algebra::Series<W, M>, oTw, rat::exp<Tm, Tw> >
241  {
242  typedef Element<algebra::Series<W, M>, rat::exp<Tm, Tw> > ret_t;
243  };
244 
245  namespace algebra {
246 
247  template<typename W, typename M, typename Tm, typename Tw, typename oTw>
248  void op_in_mul(const algebra::Series<W, M>& s,
249  const W& semiring,
250  rat::exp<Tm, Tw>& ret,
251  const oTw& w);
252 
253  template<typename W, typename M, typename Tm, typename Tw, typename oTw>
254  rat::exp<Tm, Tw> op_mul(const algebra::Series<W, M>& s,
255  const W& semiring,
256  const rat::exp<Tm, Tw>& a,
257  const oTw& w);
258 
259  template<typename W, typename M, typename oTw, typename Tm, typename Tw>
260  rat::exp<Tm, Tw> op_mul(const W& semiring,
261  const algebra::Series<W, M>& s,
262  const oTw& w,
263  const rat::exp<Tm, Tw>& b);
264 
265  /*---------------.
266  | Series methods |
267  `---------------*/
268  template<typename W, typename M, typename Tm, typename Tw, typename oTm>
269  Tw op_series_get(const algebra::Series<W, M>& s,
270  const rat::exp<Tm, Tw>& p,
271  const oTm& m);
272 
273  template<typename W, typename M, typename Tm,
274  typename Tw, typename oTm, typename oTw>
275  void op_series_set(const algebra::Series<W, M>& s,
276  const rat::exp<Tm, Tw>& p,
277  const oTm& m,
278  const oTw& w);
279 
280  template <class W, class M, class Tm, class Tw>
281  Element<algebra::Series<W,M>, rat::exp<Tm,Tw> >
282  op_choose(const algebra::Series<W,M>& s,
283  SELECTOR2(rat::exp<Tm,Tw>));
284 
285  template <typename W, typename M, typename Tm, typename Tw, typename St>
286  St&
287  op_rout(const algebra::Series<W, M>&,
288  St& st,
289  const rat::exp<Tm, Tw>&);
290 
291  /*----------.
292  | Transpose |
293  `----------*/
294 
295  template <typename W, typename M, typename Tm, typename Tw>
296  void op_in_transpose(const algebra::Series<W, M>& s,
297  rat::exp<Tm, Tw>& dst);
298 
299 
300  } // algebra
301 
302  template<typename W, typename M, typename Tm, typename Tw>
303  struct semiring_traits<algebra::Series<W, M>, rat::exp<Tm, Tw> >
304  {
305  enum { is_positive = 1 };
306  };
307 
308 } // vcsn
309 
310 
311 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
312 # include <vaucanson/algebra/implementation/series/krat.hxx>
313 #endif // VCSN_USE_INTERFACE_ONLY
314 
315 
316 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_HH