18 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_POLYNOMS_HH
19 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_POLYNOMS_HH
21 # include <vaucanson/design_pattern/design_pattern.hh>
22 # include <vaucanson/algebra/implementation/series/series.hh>
23 # include <vaucanson/algebra/implementation/series/transpose.hh>
37 template<
typename Tm,
typename Tw>
41 typedef Tm monoid_elt_value_t;
42 typedef Tw semiring_elt_value_t;
44 typedef typename std::map<Tm, Tw>::const_iterator const_iterator;
45 typedef typename std::map<Tm, Tw>::iterator iterator;
47 template<
typename M,
typename W>
49 polynom(
const polynom& other);
56 const_iterator begin()
const;
59 const_iterator end()
const;
61 iterator find(
const Tm& m);
62 const_iterator find(
const Tm& m)
const;
65 Tw& make_get(
SELECTOR(W),
const Tm& m);
67 Tw
get(
SELECTOR(W),
const Tm& m)
const;
69 void insert(
const Tm& m,
const Tw& w);
72 void add(
const W& semiring,
const Tm& m,
const Tw& w);
73 void erase(iterator i);
75 void swap(polynom<Tm, Tw>& other);
77 const std::map<Tm, Tw>&
81 operator [] (
const Tm& m)
const;
84 operator [] (
const Tm& m);
87 std::map<Tm, Tw> map_;
90 template<
typename Tm,
typename Tw>
91 struct series_traits<polynom<Tm, Tw> >
93 typedef Tm monoid_elt_value_t;
94 typedef Tw semiring_elt_value_t;
95 typedef misc::Support<std::map<Tm, Tw> > support_t;
98 template <
class Tm,
class Tw,
class W,
class M>
99 struct mute_series_impl<polynom<Tm, Tw>, W, M>
101 typedef polynom<M, W> ret;
104 template <
class Series,
class Tm,
class Tw>
105 struct DefaultTransposeFun<Series, polynom<Tm,Tw> >
108 operator()(
const Series& s,
const polynom<Tm,Tw>& l)
const;
112 Tw
transpose(
const SeriesBase<S>& s,
const Tw& w);
116 Tw
transpose(
const SemiringBase<S>& s,
const Tw& w);
119 template <
class Tm,
class Tw>
120 bool operator==(
const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
122 template <
class Tm,
class Tw>
123 bool operator!=(
const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
125 template <
class Tm,
class Tw>
126 bool operator<(const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
128 template <
class Tm,
class Tw>
129 bool operator>(
const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
131 template <
class Tm,
class Tw>
132 bool operator<=(const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
134 template <
class Tm,
class Tw>
135 bool operator>=(
const polynom<Tm, Tw>& lhs,
const polynom<Tm, Tw>& rhs);
137 template<
typename W,
typename M,
typename Tm,
typename Tw>
138 bool op_contains(
const algebra::Series<W, M>& s,
139 const algebra::polynom<Tm, Tw>& m);
141 template<
typename Self,
typename Tm,
typename Tw>
142 void op_in_star(
const algebra::SeriesBase<Self>& s,
143 algebra::polynom<Tm, Tw>& m);
145 template<
typename Self,
typename Tm,
typename Tw>
146 bool op_starable(
const algebra::SeriesBase<Self>& s,
147 const algebra::polynom<Tm, Tw>& b);
149 template<
typename W,
typename M,
typename Tm,
typename Tw>
150 bool op_is_finite_app(
const algebra::Series<W, M>& s,
151 const algebra::polynom<Tm, Tw>& m);
153 template<
typename W,
typename M,
typename Tm,
typename Tw>
154 const algebra::polynom<Tm, Tw>&
155 identity_value(
SELECTOR2(algebra::Series<W, M>),
158 template<
typename W,
typename M,
typename Tm,
typename Tw>
159 const algebra::polynom<Tm, Tw>&
160 zero_value(
SELECTOR2(algebra::Series<W, M>),
163 template<
typename W,
typename M,
typename Tm,
typename Tw>
164 void op_in_add(
const algebra::Series<W, M>& s,
165 algebra::polynom<Tm, Tw>& dst,
166 const algebra::polynom<Tm, Tw>& arg);
168 template<
typename W,
typename M,
typename Tm,
typename Tw>
169 algebra::polynom<Tm, Tw> op_add(
const algebra::Series<W, M>& s,
170 const algebra::polynom<Tm, Tw>& a,
171 const algebra::polynom<Tm, Tw>& b);
177 template<
typename W,
typename M,
typename Tm,
typename Tw>
178 algebra::polynom<Tm, Tw> op_mul(
const algebra::Series<W, M>& s,
179 const algebra::polynom<Tm, Tw>& a,
180 const algebra::polynom<Tm, Tw>& b);
182 template<
typename W,
typename M,
typename Tm,
typename Tw>
183 void op_in_mul(
const algebra::Series<W, M>& s,
184 algebra::polynom<Tm, Tw>& dst,
185 const algebra::polynom<Tm, Tw>& arg);
191 template <
typename Tm,
typename Tw,
typename W,
typename M>
192 algebra::polynom<Tm, Tw> op_convert(
SELECTOR2(algebra::Series<W, M>),
196 template<
typename Tm,
typename Tw,
typename W,
typename M,
typename oTm>
197 algebra::polynom<Tm, Tw> op_convert(
SELECTOR2(algebra::Series<W, M>),
202 template<
typename Tm,
typename Tw,
typename W,
typename M,
typename oTw>
203 algebra::polynom<Tm, Tw> op_convert(
SELECTOR2(algebra::Series<W, M>),
208 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTm>
209 void op_assign(
const algebra::Series<W, M>& s,
210 const algebra::MonoidBase<M>& monoid,
211 algebra::polynom<Tm, Tw>& dst,
214 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTw>
215 void op_assign(
const algebra::Series<W, M>& s,
216 const algebra::SemiringBase<W>& semiring,
217 algebra::polynom<Tm, Tw>& dst,
224 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTm>
225 void op_in_add(
const algebra::Series<W, M>& s,
226 const algebra::MonoidBase<M>& monoid,
227 algebra::polynom<Tm, Tw>& dst,
230 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTm>
231 algebra::polynom<Tm, Tw> op_add(
const algebra::Series<W, M>& s,
232 const algebra::MonoidBase<M>& monoid,
233 const algebra::polynom<Tm, Tw>& a,
239 template<
typename M,
typename W,
typename oTm,
typename Tm,
typename Tw>
240 struct op_add_traits<M, algebra::Series<W, M>,
241 oTm, algebra::polynom<Tm, Tw> >
243 typedef Element<algebra::Series<W, M>, algebra::polynom<Tm, Tw> > ret_t;
248 template<
typename M,
typename W,
typename oTm,
typename Tm,
typename Tw>
249 algebra::polynom<Tm, Tw> op_add(
const algebra::MonoidBase<M>& monoid,
250 const algebra::Series<W, M>& s,
252 const algebra::polynom<Tm, Tw>& b);
258 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTw>
259 void op_in_add(
const algebra::Series<W, M>& s,
260 const algebra::SemiringBase<W>& semiring,
261 algebra::polynom<Tm, Tw>& dst,
264 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTw>
265 algebra::polynom<Tm, Tw> op_add(
const algebra::Series<W, M>& s,
266 const algebra::SemiringBase<W>& semiring,
267 const algebra::polynom<Tm, Tw>& a,
272 template<
typename W,
typename M,
typename oTw,
typename Tm,
typename Tw>
273 struct op_add_traits<W, algebra::Series<W, M>,
274 oTw, algebra::polynom<Tm, Tw> >
276 typedef Element<algebra::Series<W, M>, algebra::polynom<Tm, Tw> > ret_t;
281 template<
typename W,
typename M,
typename oTw,
typename Tm,
typename Tw>
282 algebra::polynom<Tm, Tw> op_add(
const algebra::SemiringBase<W>& semiring,
283 const algebra::Series<W, M>& s,
285 const algebra::polynom<Tm, Tw>& b);
291 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTw>
292 void op_in_mul(
const algebra::Series<W, M>& s,
293 const algebra::SemiringBase<W>& semiring,
294 algebra::polynom<Tm, Tw>& dst,
297 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTw>
298 algebra::polynom<Tm, Tw> op_mul(
const algebra::Series<W, M>& s,
299 const algebra::SemiringBase<W>& semiring,
300 const algebra::polynom<Tm, Tw>& a,
305 template<
typename W,
typename M,
typename oTw,
typename Tm,
typename Tw>
306 struct op_mul_traits<W, algebra::Series<W, M>,
307 oTw, algebra::polynom<Tm, Tw> >
309 typedef Element<algebra::Series<W, M>, algebra::polynom<Tm, Tw> > ret_t;
314 template<
typename W,
typename M,
typename oTw,
typename Tm,
typename Tw>
315 algebra::polynom<Tm, Tw> op_mul(
const algebra::SemiringBase<W>& semiring,
316 const algebra::Series<W, M>& s,
318 const algebra::polynom<Tm, Tw>& b);
324 template <
typename W,
typename M,
typename Tm,
typename Tw>
325 void op_in_transpose(
const algebra::Series<W, M>& s,
326 algebra::polynom<Tm, Tw>& t);
332 template<
typename W,
typename M,
typename St,
typename Tm,
typename Tw>
333 St&
op_rout(
const algebra::Series<W, M>& s, St& st,
334 const algebra::polynom<Tm, Tw>& p);
342 template<
typename W,
typename M,
typename Tm,
typename Tw>
343 struct MetaElement<algebra::Series<W, M>, algebra::polynom<Tm, Tw> >
344 :
public MetaElement<algebra::SeriesBase<algebra::Series<W, M> >,
345 algebra::polynom<Tm, Tw> >
347 static const bool dynamic_value =
true;
356 template <
class W,
class M,
class Tm,
class Tw>
357 Tm op_choose_from_supp(
const algebra::Series<W, M>& s,
358 const algebra::polynom<Tm, Tw>& p);
360 template<
typename W,
typename M,
typename Tm,
typename Tw>
361 typename algebra::series_traits<algebra::polynom<Tm, Tw> >::support_t
362 op_support(
const algebra::Series<W, M>& s,
363 const algebra::polynom<Tm, Tw>& m);
365 template<
typename W,
typename M,
typename Tm,
typename Tw,
typename oTm>
366 Tw op_series_get(
const algebra::Series<W, M>& s,
367 const algebra::polynom<Tm, Tw>& p,
370 template<
typename W,
typename M,
371 typename Tm,
typename Tw,
372 typename oTm,
typename oTw>
373 void op_series_set(
const algebra::Series<W, M>& s,
374 algebra::polynom<Tm, Tw>& p,
378 template <
class W,
class M,
class Tm,
class Tw>
379 Element<algebra::Series<W,M>, algebra::polynom<Tm,Tw> >
380 op_choose(
const algebra::Series<W,M>& s,
387 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
388 # include <vaucanson/algebra/implementation/series/polynoms.hxx>
389 #endif // VCSN_USE_INTERFACE_ONLY
391 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_POLYNOMS_HH