Vaucanson  1.4.1
algorithms/transpose.hxx
1 // transpose.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The
6 // Vaucanson Group.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // The complete GNU General Public Licence Notice can be found as the
14 // `COPYING' file in the root directory.
15 //
16 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
17 //
18 #ifndef VCSN_ALGORITHMS_TRANSPOSE_HXX
19 # define VCSN_ALGORITHMS_TRANSPOSE_HXX
20 
22 #include <vaucanson/automata/implementation/transpose_view.hh>
23 #include <vaucanson/automata/concept/copy.hh>
24 
25 namespace vcsn
26 {
27  template<typename A, typename AI1, typename AI2>
28  void
30  {
31  BENCH_TASK_SCOPED("transpose");
32  typedef Element<A, AI1> automaton_t;
33  AUTOMATON_TYPES(automaton_t);
34  auto_copy(dst, transpose_view(from));
35  // transpose_view is still a quick transposition without label transpose.
36  // transpose now inverts all transitions of the dst_ automaton.
37  for_all_transitions(e, dst)
38  dst.series_of(*e).transpose();
39  }
40 
41  template<typename A, typename AI>
42  Element<A, AI>
44  {
45  Element<A, AI> dst(from.structure());
46  transpose(dst, from);
47  return dst;
48  }
49 
50 } //vcsn
51 
52 #endif // ! VCSN_ALGORITHMS_TRANSPOSE_HXX