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

# domain.hxx

    00001 // domain.hxx: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 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_ALGORITHMS_DOMAIN_HXX
    00018 # define VCSN_ALGORITHMS_DOMAIN_HXX
    00019
    00020 # include <vaucanson/algorithms/domain.hh>
    00021
    00022 namespace vcsn
    00023 {
    00024
    00025   /*-----------.
    00026   | FMP_Domain |
    00027   `-----------*/
    00028
    00029   template <typename src_t, typename dst_t>
    00030   void
    00031   do_fmp_domain(const src_t& src, dst_t& dst)
    00032   {
    00033     TIMER_SCOPED("fmp_domain");
    00034     AUTOMATON_TYPES_(src_t, trans_);
    00035     AUTOMATON_TYPES(dst_t);
    00036
    00037     typedef typename trans_series_set_elt_t::support_t  trans_support_t;
    00038     std::map<hstate_t, hstate_t>        stmap;
    00039
    00040     const series_set_t&         series = dst.structure().series();
    00041     const monoid_t&             monoid = dst.structure().series().monoid();
    00042     const trans_monoid_t&       trans_monoid =
    00043       src.structure().series().monoid();
    00044
    00045     set_states(src, dst, stmap);
    00046
    00047     for_all_transitions(fmp_e, src)
    00048     {
    00049       const trans_series_set_elt_t      trans_series_elt =
    00050         src.series_of(*fmp_e);
    00051       trans_support_t                   trans_supp = trans_series_elt.supp();
    00052       const trans_monoid_elt_t  trans_monoid_elt
    00053         (trans_monoid, *(trans_supp.begin()));
    00054       const monoid_elt_value_t  word(trans_monoid_elt.value().first);
    00055
    00056       series_set_elt_t          series_elt(series);
    00057
    00058       series_elt.assoc(monoid_elt_t(monoid, word),
    00059                        trans_series_elt.get(trans_monoid_elt));
    00060
    00061       dst.add_series_transition(stmap[src.src_of(*fmp_e)],
    00062                                 stmap[src.dst_of(*fmp_e)], series_elt);
    00063     }
    00064   }
    00065
    00066 // FIXME: non void version
    00067
    00068
    00069   /*----------.
    00070   | RW_Domain |
    00071   `----------*/
    00072
    00073   template <typename src_t, typename dst_t>
    00074   void
    00075   do_rw_domain(const src_t& src, dst_t& dst)
    00076   {
    00077     TIMER_SCOPED("rw_domain");
    00078     std::map<hstate_t, hstate_t> m;
    00079     AUTOMATON_TYPES(src_t);
    00080
    00081     for_all_states(p, src)
    00082     {
    00083       m[*p] = dst.add_state();
    00084     }
    00085
    00086     for_all_initial_states(p, src)
    00087       dst.set_initial(m[*p]);
    00088
    00089     for_all_final_states(p, src)
    00090       dst.set_final(m[*p]);
    00091
    00092     for_all_transitions(e, src)
    00093     {
    00094       dst.add_series_transition(m[src.src_of(*e)],
    00095                                 m[src.dst_of(*e)],
    00096                                 src.input_of(*e));
    00097     }
    00098   }
    00099
    00100 // FIXME: non void version
    00101
    00102
    00103   /*-----------------.
    00104   | Dispatch methods |
    00105   `-----------------*/
    00106
    00107   template <typename S, typename S2, typename T, typename T2>
    00108   void
    00109   domain_dispatch(const AutomataBase<S>&, const Element<S,T>& src, Element<S2, T2>& dst)
    00110   {
    00111     do_fmp_domain(src, dst);
    00112   }
    00113
    00114   template <typename S, typename S2, typename T, typename T2>
    00115   void
    00116   domain_dispatch(const TransducerBase<S>&, const Element<S,T>& src, Element<S2, T2>& dst)
    00117   {
    00118     do_rw_domain(src, dst);
    00119   }
    00120
    00121   template <typename S, typename S2, typename T, typename T2>
    00122   void
    00123   domain(const Element<S,T>& src, Element<S2, T2>& dst)
    00124   {
    00125     domain_dispatch(src.structure(), src, dst);
    00126   }
    00127
    00128 } // End of namespace vcsn.
    00129
    00130 #endif // ! VCSN_ALGORITHMS_DOMAIN_HXX