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 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 S>
00104   struct virtual_types<algebra::SeriesBase<S> >
00105     : virtual_types<algebra::SemiringBase<S> >
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 
00146     void                assoc(const monoid_elt_value_t& m,
00147                               const semiring_elt_value_t& w);
00148 
00150     void                assoc(const monoid_elt_t& m, const semiring_elt_t& w);
00151 
00153     bool                is_finite_app() const;
00154 
00156     monoid_elt_t        choose_from_supp() const;
00157 
00159     void                transpose();
00160 
00168     support_t           supp() const;
00169 
00170   protected:
00172     MetaElement();
00173 
00175     MetaElement(const MetaElement& other);
00176   };
00177 
00179   template <typename S, typename T>
00180   Element<S, T>
00181   transpose(const algebra::SeriesBase<S>& s, const T& t);
00182 
00184   template <typename S, typename T>
00185   bool
00186   is_letter_support(const Element<S, T>& s);
00187 
00189   template <typename S1, typename S2, typename T1, typename T2>
00190   void
00191   extract_support(Element<S1, T1>&, Element<S2, T2>&);
00192 
00194   template <class S, class T>
00195   Element<S, T> hadamard(const Element<S, T>& lhs,
00196                          const Element<S, T>& rhs);
00197 
00201   template <typename S, typename T>
00202   bool
00203   op_is_finite_app(const algebra::SeriesBase<S>& s, const T& t);
00204 
00205   template <typename S, typename T>
00206   typename MetaElement<algebra::SeriesBase<S>, T>::monoid_elt_t
00207 
00208   op_choose_from_supp(const algebra::SeriesBase<S>& s, const T& t);
00209 
00210   template <class S, class T>
00211   Element<S, T> op_series_choose(const algebra::SeriesBase<S>& s, SELECTOR(T));
00212 
00213   template <typename S, typename T, typename M, typename W>
00214   void
00215   op_series_set(const algebra::SeriesBase<S>& s, const T& t, const W& w);
00216 
00217   template <class S, class T>
00218   typename algebra::series_traits<T>::support_t
00219   op_support(const algebra::SeriesBase<S>&, const T& v);
00220 
00221   // This conversion is needed when assigning a monoid element to a series.
00222   template <class S, class M>
00223   S
00224   op_convert(const algebra::SeriesBase<S>&,
00225              const algebra::FreeMonoidBase<M>&);
00226 
00227   template <class S, class T>
00228   T op_convert(const algebra::SeriesBase<S>& s, SELECTOR(T), const T& src_);
00229 
00230   template <class S, class T, class U>
00231   T op_convert(const algebra::SeriesBase<S>&, SELECTOR(T), U& src_);
00232 
00233 } // vcsn
00234 
00235 # ifndef VCSN_USE_INTERFACE_ONLY
00236 #  include <vaucanson/algebra/concept/series_base.hxx>
00237 # endif // VCSN_USE_INTERFACE_ONLY
00238 
00239 #endif // ! VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH

Generated on Fri Jul 28 12:18:51 2006 for Vaucanson by  doxygen 1.4.6