- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# series_base.hh

    00001 // series_base.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Vaucanson Group.
    00006 //
    00007 // This program is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU General Public License
    00009 // as published by the Free Software Foundation; either version 2
    00010 // of the License, or (at your option) any later version.
    00011 //
    00012 // The complete GNU General Public Licence Notice can be found as the
    00013 // `COPYING' file in the root directory.
    00014 //
    00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    00016 //
    00017 #ifndef VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH
    00018 # define VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH
    00019
    00020 # include <vaucanson/algebra/concept/semiring_base.hh>
    00021 # include <vaucanson/algebra/concept/freemonoid_base.hh>
    00022
    00023 namespace vcsn {
    00024
    00025   namespace algebra {
    00026
    00030     /*-----------------.
    00031     | SeriesBase<Self> |
    00032     `-----------------*/
    00033
    00036     template<class Self>
    00037     struct SeriesBase
    00038       : SemiringBase<Self>
    00039     {
    00041       typedef typename virtual_types<Self>::monoid_t  monoid_t;
    00042
    00044       typedef typename virtual_types<Self>::semiring_t semiring_t;
    00045
    00047       const monoid_t&   monoid() const;
    00048
    00050       const semiring_t&  semiring() const;
    00051
    00053       monoid_t&         monoid();
    00054
    00056       semiring_t&       semiring();
    00057
    00058     protected:
    00060       SeriesBase();
    00061
    00063       SeriesBase(const SeriesBase& other);
    00064     };
    00065
    00067     template<typename T>
    00068     struct series_traits
    00069     {
    00070       typedef undefined_type    monoid_elt_value_t;
    00071       typedef undefined_type    semiring_elt_value_t;
    00072     };
    00073
    00074     template <typename T, typename W, typename M>
    00075     struct mute_series_impl
    00076     {
    00077       typedef undefined_type    ret;
    00078     };
    00079
    00080     template <typename T, typename W, typename M>
    00081     struct mute_series_traits
    00082     {
    00083       typedef undefined_type    ret;
    00084     };
    00085
    00089   } // algebra
    00090
    00094   /*----------------------------------.
    00095   | dynamic_traits<SeriesBase<Self> > |
    00096   `----------------------------------*/
    00097
    00098   template<typename Self>
    00099   struct dynamic_traits<algebra::SeriesBase<Self> >
    00100     : dynamic_traits<algebra::SemiringBase<Self> >
    00101   {};
    00102
    00103   template<typename Self>
    00104   struct virtual_types<algebra::SeriesBase<Self> >
    00105     : virtual_types<algebra::SemiringBase<Self> >
    00106   {
    00107     typedef undefined_type monoid_t;
    00108     typedef undefined_type semiring_t;
    00109   };
    00110
    00111   /*---------------------------------.
    00112   | MetaElement<SeriesBase<Self>, T> |
    00113   `---------------------------------*/
    00114
    00116   template<class Self, typename T>
    00117   class MetaElement<algebra::SeriesBase<Self>, T>
    00118     : public MetaElement<algebra::SemiringBase<Self>, T>
    00119   {
    00120   public:
    00122     typedef typename algebra::series_traits<T>::semiring_elt_value_t   semiring_elt_value_t;
    00123
    00125     typedef typename algebra::series_traits<T>::monoid_elt_value_t    monoid_elt_value_t;
    00126
    00128     typedef Element<typename Self::semiring_t, semiring_elt_value_t> semiring_elt_t;
    00129
    00131     typedef Element<typename Self::monoid_t, monoid_elt_value_t>         monoid_elt_t;
    00132
    00134     typedef typename Self::monoid_t     monoid_t;
    00135
    00137     typedef typename Self::semiring_t   semiring_t;
    00138
    00140     typedef Self        series_set_t;
    00141
    00143     typedef Element<Self, T>                             element_t;
    00144
    00146     typedef typename algebra::series_traits<T>::support_t       support_t;
    00147
    00149     semiring_elt_value_t        get(const monoid_elt_value_t& m) const;
    00150
    00152     semiring_elt_t              get(const monoid_elt_t& m) const;
    00153
    00157     void assoc(const monoid_elt_value_t& m, const semiring_elt_value_t& w);
    00158
    00162     void assoc(const monoid_elt_t& m, const semiring_elt_t& w);
    00163
    00165     bool is_finite_app() const;
    00166
    00168     monoid_elt_t choose_from_supp() const;
    00169
    00171     void transpose();
    00172
    00180     support_t           supp() const;
    00181
    00182     series_set_t        series() const;
    00183
    00184   protected:
    00186     MetaElement();
    00187
    00189     MetaElement(const MetaElement& other);
    00190   };
    00191
    00193   template <typename S, typename T>
    00194   Element<S, T>
    00195   transpose(const algebra::SeriesBase<S>& s, const T& t);
    00196
    00198   template <typename S, typename T>
    00199   bool
    00200   is_support_in_alphabet(const Element<S, T>& s);
    00201
    00203   template <typename S1, typename S2, typename T1, typename T2>
    00204   void
    00205   extract_support(Element<S1, T1>&, Element<S2, T2>&);
    00206
    00208   template <class S, class T>
    00209   Element<S, T> hadamard(const Element<S, T>& lhs,
    00210                          const Element<S, T>& rhs);
    00211
    00216   /*------.
    00217   | Ops.  |
    00218   `------*/
    00219
    00220   namespace algebra {
    00221
    00222     template <typename S, typename T>
    00223     bool
    00224     op_is_finite_app(const algebra::SeriesBase<S>& s, const T& t);
    00225
    00226     template <typename S, typename T>
    00227     typename MetaElement<algebra::SeriesBase<S>, T>::monoid_elt_t
    00228     op_choose_from_supp(const algebra::SeriesBase<S>& s, const T& t);
    00229
    00230     template <class S, class T>
    00231     Element<S, T>
    00232     op_series_choose(const algebra::SeriesBase<S>& s, SELECTOR(T));
    00233
    00234     template <typename S, typename T, typename M, typename W>
    00235     void
    00236     op_series_set(const algebra::SeriesBase<S>& s, const T& t, const W& w);
    00237
    00238     template <class S, class T>
    00239     typename algebra::series_traits<T>::support_t
    00240     op_support(const algebra::SeriesBase<S>&, const T& v);
    00241
    00242     // This conversion is needed when assigning a monoid element to a series.
    00243     template <class S, class M>
    00244     S
    00245     op_convert(const algebra::SeriesBase<S>&,
    00246                const algebra::FreeMonoidBase<M>&);
    00247
    00248     template <class S, class T>
    00249     T
    00250     op_convert(const algebra::SeriesBase<S>& s, SELECTOR(T), const T& src_);
    00251
    00252     template <class S, class T, class U>
    00253     T
    00254     op_convert(const algebra::SeriesBase<S>&, SELECTOR(T), U& src_);
    00255
    00257     template<typename S, typename St, typename T>
    00258     St& op_rout(const algebra::SeriesBase<S>& s, St& st, const T& se);
    00259
    00260   } // algebra
    00261
    00262 } // vcsn
    00263
    00264 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00265 #  include <vaucanson/algebra/concept/series_base.hxx>
    00266 # endif // VCSN_USE_INTERFACE_ONLY
    00267
    00268 #endif // ! VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH