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

# fmp_transducer_maker.thxx

    00001 //                                                      -*- C++ -*-
    00002 // fmp_transducer_maker.thxx: this file is part of the Vaucanson project.
    00003 //
    00004 // Vaucanson, a generic library for finite state machines.
    00005 //
    00006 // Copyright (C) 2005, 2006 The Vaucanson Group.
    00007 //
    00008 // This program is free software; you can redistribute it and/or
    00009 // modify it under the terms of the GNU General Public License
    00010 // as published by the Free Software Foundation; either version 2
    00011 // of the License, or (at your option) any later version.
    00012 //
    00013 // The complete GNU General Public Licence Notice can be found as the
    00014 // `COPYING' file in the root directory.
    00015 //
    00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    00017 //
    00018
    00019 /*
    00020  * CPP guard should not be inserted here as
    00021  * VCSN_CONTEXT_NAMESPACE could be changed.
    00022  */
    00023
    00024 #include <vaucanson/algorithms/minimization_hopcroft.hh>
    00025 #include <vaucanson/algorithms/evaluation_fmp.hh>
    00026 #include <vaucanson/algorithms/aut_to_exp.hh>
    00027 #include <vaucanson/algorithms/trim.hh>
    00028 #include <vaucanson/algorithms/realtime.hh>
    00029
    00030 namespace vcsn
    00031 {
    00032   VCSN_CONTEXT_NAMESPACE
    00033   {
    00034
    00035     template <class FirstInputIterator, class SecondInputIterator>
    00036     automata_set_t make_automata_set(const FirstInputIterator first_begin,
    00037                                      const FirstInputIterator first_end,
    00038                                      const SecondInputIterator second_begin,
    00039                                      const SecondInputIterator second_end)
    00040     {
    00041       first_alphabet_t          first_alpha;
    00042       for (FirstInputIterator e = first_begin; e != first_end; ++e)
    00043         first_alpha.insert(*e);
    00044
    00045       second_alphabet_t         second_alpha;
    00046       for (SecondInputIterator e = second_begin; e != second_end; ++e)
    00047         second_alpha.insert(*e);
    00048
    00049       semiring_t                semiring;
    00050       monoid_t                  freemonoidproduct (first_alpha, second_alpha);
    00051       series_set_t              series (semiring, freemonoidproduct);
    00052       return automata_set_t     (series);
    00053     }
    00054
    00055
    00056     template <class FirstInputIterator, class SecondInputIterator>
    00057     automaton_t make_automaton(const FirstInputIterator first_begin,
    00058                                const FirstInputIterator first_end,
    00059                                const SecondInputIterator second_begin,
    00060                                const SecondInputIterator second_end)
    00061     {
    00062       return automaton_t (make_automata_set(first_begin, first_end,
    00063                                             second_begin, second_end));
    00064     }
    00065
    00066     template <class T1, class T2>
    00067     automaton_t make_automaton(const T1& first_alphabet,
    00068                                const T2& second_alphabet)
    00069     {
    00070       return make_automaton(first_alphabet.begin(), first_alphabet.end(),
    00071                             second_alphabet.begin(), second_alphabet.end());
    00072     }
    00073
    00074     template <class FirstIterator, class SecondIterator>
    00075     monoid_elt_t make_couple(const FirstIterator first_begin,
    00076                              const FirstIterator first_end,
    00077                              const SecondIterator second_begin,
    00078                              const SecondIterator second_end,
    00079                              const std::string& first_exp,
    00080                              const std::string& second_exp)
    00081     {
    00082       first_alphabet_t          first_alpha;
    00083       for (FirstIterator e = first_begin; e != first_end; ++e)
    00084         first_alpha.insert(*e);
    00085
    00086       second_alphabet_t         second_alpha;
    00087       for (SecondIterator e = second_begin; e != second_end; ++e)
    00088         second_alpha.insert(*e);
    00089
    00090       monoid_t                  fmp (first_alpha, second_alpha);
    00091
    00092       monoid_elt_value_t        fmp_elt_value (first_exp, second_exp);
    00093       return Element<monoid_t, monoid_elt_value_t> (fmp, fmp_elt_value);
    00094     }
    00095
    00096     template <class T1, class T2>
    00097     monoid_elt_t make_couple(const T1& first_alphabet,
    00098                              const T2& second_alphabet,
    00099                              const std::string& first_exp,
    00100                              const std::string& second_exp)
    00101     {
    00102       return make_couple(first_alphabet.begin(), first_alphabet.end(),
    00103                          second_alphabet.begin(), second_alphabet.end(),
    00104                          first_exp, second_exp);
    00105     }
    00106
    00107
    00108     template <typename TransStruct,
    00109               typename TransImpl,
    00110               typename SeriesStruct,
    00111               typename SeriesImpl,
    00112               typename S,
    00113               typename T>
    00114     AUTOMATON_CONTEXT::rat_exp_t
    00115     do_evaluation(const vcsn::AutomataBase<TransStruct>&,
    00116                   const TransImpl&,
    00117                   const SeriesStruct&,
    00118                   const vcsn::rat::exp<S, T>& input,
    00119                   const Element<TransStruct, TransImpl>& t,
    00120                   const Element<SeriesStruct, SeriesImpl>&)
    00121     {
    00122       AUTOMATON_CONTEXT::automaton_t w = AUTOMATON_CONTEXT::make_automaton(t.structure().series()
    00123           .monoid().first_monoid().alphabet());
    00124       AUTOMATON_CONTEXT::automaton_t result = AUTOMATON_CONTEXT::make_automaton(t.structure().series()
    00125           .monoid().second_monoid().alphabet());
    00126       standard_of(w, input);
    00127       evaluation_fmp(t, quotient(w), result);
    00128       return aut_to_exp(generalized(quotient(realtime(trim(result)))),
    00129                         DMChooser());
    00130     }
    00131
    00132
    00133     template <typename TransStruct,
    00134               typename TransImpl,
    00135               typename ArgStruct,
    00136               typename ArgImpl>
    00137     AUTOMATON_CONTEXT::rat_exp_t
    00138     evaluation(const Element<TransStruct, TransImpl>& t,
    00139                const Element<ArgStruct, ArgImpl>& input)
    00140     {
    00141       return do_evaluation(t.structure(), t.value(),
    00142                            input.structure(), input.value(),
    00143                            t, input);
    00144     }
    00145
    00146
    00147   } // End of VCSN_CONTEXT_NAMESPACE.
    00148 } // End of namespace vcsn.
    00149