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 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 Element<Self, T>                             element_t;
00135 
00137     typedef typename algebra::series_traits<T>::support_t       support_t;
00138 
00140     semiring_elt_value_t        get(const monoid_elt_value_t& m) const;
00141 
00143     semiring_elt_t              get(const monoid_elt_t& m) const;
00144 
00148     void assoc(const monoid_elt_value_t& m, const semiring_elt_value_t& w);
00149 
00153     void assoc(const monoid_elt_t& m, const semiring_elt_t& w);
00154 
00156     bool is_finite_app() const;
00157 
00159     monoid_elt_t choose_from_supp() const;
00160 
00162     void transpose();
00163 
00171     support_t           supp() const;
00172 
00173   protected:
00175     MetaElement();
00176 
00178     MetaElement(const MetaElement& other);
00179   };
00180 
00182   template <typename S, typename T>
00183   Element<S, T>
00184   transpose(const algebra::SeriesBase<S>& s, const T& t);
00185 
00187   template <typename S, typename T>
00188   bool
00189   is_letter_support(const Element<S, T>& s);
00190 
00192   template <typename S1, typename S2, typename T1, typename T2>
00193   void
00194   extract_support(Element<S1, T1>&, Element<S2, T2>&);
00195 
00197   template <class S, class T>
00198   Element<S, T> hadamard(const Element<S, T>& lhs,
00199                          const Element<S, T>& rhs);
00200 
00205   /*------.
00206   | Ops.  |
00207   `------*/
00208 
00209   template <typename S, typename T>
00210   bool
00211   op_is_finite_app(const algebra::SeriesBase<S>& s, const T& t);
00212 
00213   template <typename S, typename T>
00214   typename MetaElement<algebra::SeriesBase<S>, T>::monoid_elt_t
00215   op_choose_from_supp(const algebra::SeriesBase<S>& s, const T& t);
00216 
00217   template <class S, class T>
00218   Element<S, T> 
00219   op_series_choose(const algebra::SeriesBase<S>& s, SELECTOR(T));
00220 
00221   template <typename S, typename T, typename M, typename W>
00222   void
00223   op_series_set(const algebra::SeriesBase<S>& s, const T& t, const W& w);
00224 
00225   template <class S, class T>
00226   typename algebra::series_traits<T>::support_t
00227   op_support(const algebra::SeriesBase<S>&, const T& v);
00228 
00229   // This conversion is needed when assigning a monoid element to a series.
00230   template <class S, class M>
00231   S
00232   op_convert(const algebra::SeriesBase<S>&,
00233              const algebra::FreeMonoidBase<M>&);
00234 
00235   template <class S, class T>
00236   T
00237   op_convert(const algebra::SeriesBase<S>& s, SELECTOR(T), const T& src_);
00238 
00239   template <class S, class T, class U>
00240   T
00241   op_convert(const algebra::SeriesBase<S>&, SELECTOR(T), U& src_);
00242 
00243 } // vcsn
00244 
00245 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00246 #  include <vaucanson/algebra/concept/series_base.hxx>
00247 # endif // VCSN_USE_INTERFACE_ONLY
00248 
00249 #endif // ! VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH

Generated on Sun Jul 29 19:35:29 2007 for Vaucanson by  doxygen 1.5.2