Vaucanson 1.4
|
00001 // factor.hxx: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2011 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_FACTOR_HXX 00018 # define VCSN_ALGORITHMS_FACTOR_HXX 00019 00020 # include <vaucanson/algorithms/factor.hh> 00021 00022 # include <vaucanson/automata/concept/automata_base.hh> 00023 # include <vaucanson/algorithms/realtime.hh> 00024 # include <vaucanson/automata/implementation/transpose_view.hh> 00025 # include <vaucanson/misc/usual_macros.hh> 00026 # include <vaucanson/algorithms/is_trim.hh> 00027 00028 namespace vcsn { 00029 00030 /*--------------. 00031 | factor_here | 00032 `--------------*/ 00033 00034 template<typename A, typename AI> 00035 void 00036 factor_here (Element<A, AI>& a) 00037 { 00038 precondition(is_realtime(a)); 00039 precondition(is_trim(a)); 00040 00041 typedef Element<A, AI> automaton_t; 00042 AUTOMATON_TYPES (automaton_t); 00043 00044 for_all_states (i, a) 00045 { 00046 a.set_initial (*i); 00047 a.set_final (*i); 00048 } 00049 } 00050 00051 /*---------. 00052 | factor | 00053 `---------*/ 00054 00055 template<typename A, typename AI> 00056 Element<A, AI> 00057 factor (const Element<A, AI>& a) 00058 { 00059 Element<A, AI> res (a); 00060 factor_here (res); 00061 return (res); 00062 } 00063 00064 } // vcsn 00065 00066 #endif // !VCSN_ALGORITHMS_FACTOR_HXX