00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HXX
00018 # define VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HXX
00019
00020 #include <vaucanson/automata/concept/transducer_base.hh>
00021
00022 namespace vcsn {
00023
00024 template <class Series>
00025 Transducer<Series>::Transducer(const series_set_t& s):
00026 SetSlot<Series>(s)
00027 {}
00028
00029 template <class Series>
00030 const typename Transducer<Series>::series_set_t&
00031 Transducer<Series>::series() const
00032 {
00033 return this->_structure_get();
00034 }
00035
00036 template <class Series>
00037 bool
00038 operator==(const Transducer<Series>& lhs,
00039 const Transducer<Series>& rhs)
00040 {
00041 return & lhs.series() == & rhs.series();
00042 }
00043
00044 template <class S, class T>
00045 typename identity_transducer_helper<S, T>::ret
00046 partial_identity(const Element<S, T>& a)
00047 {
00048 typedef Element<S, T> automaton_t;
00049 AUTOMATON_TYPES(automaton_t);
00050 typedef typename identity_transducer_helper<S, T>::ret ret_t;
00051 typedef typename ret_t::series_set_elt_t output_series_set_elt_t;
00052 typedef typename series_set_elt_t::support_t support_t;
00053 typedef typename ret_t::set_t set_t;
00054 typedef typename set_t::series_set_t o_series_set_t;
00055 set_t s (o_series_set_t (a.structure().series(),
00056 a.structure().series().monoid()));
00057 ret_t ret(s);
00058 std::vector<hstate_t> conv(a.states().size());
00059
00060 for_each_state(s, a)
00061 conv[ret.add_state()] = *s;
00062 for_each_transition(e, a)
00063 {
00064 series_set_elt_t t = a.series_of(*e);
00065 series_set_elt_t s(t);
00066 output_series_set_elt_t os(ret.structure().series());
00067 support_t supp = s.supp();
00068 for_each_const_(support_t, m, supp)
00069 {
00070 series_set_elt_t tmp(a.structure().series());
00071 tmp.assoc(*m, s.get(*m));
00072 os.assoc(*m, tmp);
00073 }
00074 htransition_t f = ret.add_series_transition(conv[a.src_of(*e)],
00075 conv[a.dst_of(*e)],
00076 os);
00077 }
00078
00079 for_each_initial_state(i, a)
00080 ret.set_initial(conv[*i], a.get_initial(*i));
00081 for_each_final_state(f, a)
00082 ret.set_final(conv[*f], a.get_final(*f));
00083 return ret;
00084 }
00085
00086 }
00087
00088 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HXX