Vaucanson  1.4.1
factor.hxx
1 // factor.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2011 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGORITHMS_FACTOR_HXX
18 # define VCSN_ALGORITHMS_FACTOR_HXX
19 
21 
22 # include <vaucanson/automata/concept/automata_base.hh>
24 # include <vaucanson/automata/implementation/transpose_view.hh>
25 # include <vaucanson/misc/usual_macros.hh>
27 
28 namespace vcsn {
29 
30  /*--------------.
31  | factor_here |
32  `--------------*/
33 
34  template<typename A, typename AI>
35  void
36  factor_here (Element<A, AI>& a)
37  {
38  precondition(is_realtime(a));
39  precondition(is_trim(a));
40 
41  typedef Element<A, AI> automaton_t;
42  AUTOMATON_TYPES (automaton_t);
43 
44  for_all_states (i, a)
45  {
46  a.set_initial (*i);
47  a.set_final (*i);
48  }
49  }
50 
51  /*---------.
52  | factor |
53  `---------*/
54 
55  template<typename A, typename AI>
56  Element<A, AI>
58  {
59  Element<A, AI> res (a);
60  factor_here (res);
61  return (res);
62  }
63 
64 } // vcsn
65 
66 #endif // !VCSN_ALGORITHMS_FACTOR_HXX