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, 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 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 
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 
00204   template <typename S, typename T>
00205   bool
00206   op_is_finite_app(const algebra::SeriesBase<S>& s, const T& t);
00207 
00208   template <typename S, typename T>
00209   typename MetaElement<algebra::SeriesBase<S>, T>::monoid_elt_t
00210 
00211   op_choose_from_supp(const algebra::SeriesBase<S>& s, const T& t);
00212 
00213   template <class S, class T>
00214   Element<S, T> op_series_choose(const algebra::SeriesBase<S>& s, SELECTOR(T));
00215 
00216   template <typename S, typename T, typename M, typename W>
00217   void
00218   op_series_set(const algebra::SeriesBase<S>& s, const T& t, const W& w);
00219 
00220   template <class S, class T>
00221   typename algebra::series_traits<T>::support_t
00222   op_support(const algebra::SeriesBase<S>&, const T& v);
00223 
00224   // This conversion is needed when assigning a monoid element to a series.
00225   template <class S, class M>
00226   S
00227   op_convert(const algebra::SeriesBase<S>&,
00228              const algebra::FreeMonoidBase<M>&);
00229 
00230   template <class S, class T>
00231   T op_convert(const algebra::SeriesBase<S>& s, SELECTOR(T), const T& src_);
00232 
00233   template <class S, class T, class U>
00234   T op_convert(const algebra::SeriesBase<S>&, SELECTOR(T), U& src_);
00235 
00236 } // vcsn
00237 
00238 # ifndef VCSN_USE_INTERFACE_ONLY
00239 #  include <vaucanson/algebra/concept/series_base.hxx>
00240 # endif // VCSN_USE_INTERFACE_ONLY
00241 
00242 #endif // ! VCSN_ALGEBRA_CONCEPT_SERIES_BASE_HH

Generated on Sat Jul 29 17:13:10 2006 for Vaucanson by  doxygen 1.4.6