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

# brzozowski.hxx

    00001 // brzozowski.hxx: 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, 2005, 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_BRZOZOWSKI_HXX
    00018 # define VCSN_ALGORITHMS_BRZOZOWSKI_HXX
    00019
    00020 # include <vaucanson/algorithms/brzozowski.hh>
    00021
    00022 # include <vaucanson/algorithms/internal/build_pattern.hh>
    00023 # include <vaucanson/automata/concept/automata_base.hh>
    00024
    00025 # include <vaucanson/algorithms/krat_exp_constant_term.hh>
    00026 # include <vaucanson/algorithms/krat_exp_derivation.hh>
    00027 # include <vaucanson/algorithms/aci_canonical.hh>
    00028 # include <vaucanson/misc/usual_macros.hh>
    00029
    00030 namespace vcsn {
    00031
    00032   using namespace algorithm_patterns;
    00033
    00046   template <typename T_auto, typename Exp>
    00047   struct BrzozowskiAlgo : public IncAutomataConstructor <
    00048     BrzozowskiAlgo<T_auto, Exp>,
    00049     T_auto,
    00050     Exp >
    00051   {
    00052     AUTOMATON_TYPES(T_auto);
    00053     AUTOMATON_FREEMONOID_TYPES(T_auto);
    00054
    00055     BrzozowskiAlgo(const series_set_t& series, const Exp& exp):
    00056       IncAutomataConstructor<BrzozowskiAlgo, T_auto, Exp>(series, exp)
    00057     {}
    00058
    00060     void on_state(const Exp& e)
    00061     {
    00062       alphabet_t alpha = this->get()->series().monoid().alphabet();
    00063       if (constant_term(e).first
    00064           != e.structure().semiring().zero(SELECT(semiring_elt_value_t)))
    00065         this->set_final();
    00066       for (alphabet_iterator i = alpha.begin(); i != alpha.end(); ++i)
    00067         this->link_to(canonical(derivate(e, *i).first), *i);
    00068     }
    00069   };
    00070
    00071   template<typename T_auto, typename Exp>
    00072   T_auto*
    00073   do_brzozowski(const T_auto& out, const Exp &kexp)
    00074   {
    00075     BrzozowskiAlgo<T_auto, Exp> brzozowski_algo(out.series(), canonical(kexp));
    00076     brzozowski_algo.run();
    00077     return brzozowski_algo.get();
    00078   }
    00079
    00080   template<typename A, typename T, typename Exp>
    00081   void
    00082   brzozowski(Element<A, T>& out, const Exp& kexp)
    00083   {
    00084     TIMER_SCOPED("brzozowski");
    00085     out = *do_brzozowski(out, kexp);
    00086   }
    00087
    00088 } // vcsn
    00089
    00090 #endif // ! VCSN_ALGORITHMS_BRZOZOWSKI_HXX