17 #ifndef VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HXX
18 # define VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HXX
20 # include <vaucanson/algebra/concept/series_base.hh>
21 # include <vaucanson/misc/usual_macros.hh>
32 const typename SeriesBase<Self>::monoid_t&
35 return this->
self().monoid();
42 return this->
self().semiring();
49 return this->
self().monoid();
75 template<
typename Self,
typename T>
80 return op_series_get(this->structure(), this->value(), m);
83 template<
typename Self,
typename T>
90 template<
typename Self,
typename T>
97 return op_series_set(this->structure(), this->value(), m, w);
100 template<
typename Self,
typename T>
108 template<
typename Self,
typename T>
112 return op_is_finite_app(this->structure(), this->value());
115 template <
typename Self,
typename T>
121 (this->structure().monoid(),
122 op_choose_from_supp(this->structure(), this->value()));
125 template <
typename Self,
typename T>
129 op_in_transpose(this->structure(), this->value());
132 template <
typename Self,
typename T>
136 return op_support(this->structure(), this->value());
139 template <
typename Self,
typename T>
143 return this->structure();
146 template<
typename Self,
typename T>
150 template<
typename Self,
typename T>
162 template<
typename S,
typename T>
168 template<
typename S,
typename T,
typename M,
typename W>
169 void op_series_structure(
const algebra::SeriesBase<S>& s,
const T& t,
const W& w)
171 pure_service_call (
"default implementation of op_series_structure()");
174 template <
class S,
class T>
176 op_series_choose(
const algebra::SeriesBase<S>& s,
SELECTOR(T))
178 pure_service_call (
"default implementation of op_series_choose()");
179 return Element<S, T>();
182 template <
class S,
class T>
183 typename algebra::series_traits<T>::support_t
184 op_support(
const algebra::SeriesBase<S>&,
const T& v)
191 template <
class S,
class T>
200 template <
class S,
class T>
205 support_t supp = s.supp();
206 for_all_const_(support_t, e, supp)
207 if (op_size(s.
structure().monoid(), *e) != 1)
212 template <
typename S1,
typename S2,
typename T1,
typename T2>
217 typedef typename algebra::series_traits<T1>::semiring_elt_value_t
218 semiring_elt_value_t;
219 for_all_const_(support_t, e, s2.supp())
221 algebra::identity_as<semiring_elt_value_t>::
225 template <
class S,
class T>
234 support_t support = lhs.supp();
235 for (
typename support_t::iterator supp = support.begin();
236 supp != support.end();
239 output += lhs.get(*supp) *
240 rhs.get(*supp) * series_set_elt_t(lhs.
structure(), monoid_elt_t(*supp));
247 template <
class S,
class M>
249 op_convert(
const algebra::SeriesBase<S>&,
250 const algebra::FreeMonoidBase<M>& monoid)
253 enum { compatible = misc::static_eq<typename S::monoid_t, M>::value };
254 static_assertion_(compatible, invalid_conversion_from_monoid_to_series);
256 typename S::semiring_t semiring;
257 return S (semiring, monoid.self());
260 template <
class S,
class T>
262 op_convert(
const algebra::SeriesBase<S>&,
SELECTOR(T),
const T& src_)
267 template <
class S,
class T,
class U>
269 op_convert(
const algebra::SeriesBase<S>& s,
SELECTOR(T),
const U& src_)
271 typedef typename algebra::series_traits<U>::support_t support_t;
272 typedef typename Element<S, T>::monoid_elt_t monoid_elt_t;
274 Element<S, U> src(ts, src_);
275 Element<S, T> dst(ts);
276 support_t support = src.supp();
277 for_all_const_(support_t, ss, support)
278 dst += src.
get(monoid_elt_t(s.monoid(), *ss)) *
279 Element<S, T>(s.self(), monoid_elt_t(s.monoid(), *ss));
284 template<typename S, typename St, typename T>
287 return op_rout(s.self(), st, se);
293 #endif // ! VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HXX