Vaucanson 1.4
transpose.hxx
00001 // transpose.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, 2008 The
00006 // Vaucanson Group.
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // The complete GNU General Public Licence Notice can be found as the
00014 // `COPYING' file in the root directory.
00015 //
00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00017 //
00018 #ifndef VCSN_ALGORITHMS_TRANSPOSE_HXX
00019 # define VCSN_ALGORITHMS_TRANSPOSE_HXX
00020 
00021 #include <vaucanson/algorithms/transpose.hh>
00022 #include <vaucanson/automata/implementation/transpose_view.hh>
00023 #include <vaucanson/automata/concept/copy.hh>
00024 
00025 namespace vcsn
00026 {
00027   template<typename A, typename AI1, typename AI2>
00028   void
00029   transpose(Element<A, AI1>& dst, const Element<A, AI2>& from)
00030   {
00031     BENCH_TASK_SCOPED("transpose");
00032     typedef Element<A, AI1> automaton_t;
00033     AUTOMATON_TYPES(automaton_t);
00034     auto_copy(dst, transpose_view(from));
00035     // transpose_view is still a quick transposition without label transpose.
00036     // transpose now inverts all transitions of the dst_ automaton.
00037     for_all_transitions(e, dst)
00038       dst.series_of(*e).transpose();
00039   }
00040 
00041   template<typename A, typename AI>
00042   Element<A, AI>
00043   transpose(const Element<A, AI>& from)
00044   {
00045     Element<A, AI> dst(from.structure());
00046     transpose(dst, from);
00047     return dst;
00048   }
00049 
00050 } //vcsn
00051 
00052 #endif // ! VCSN_ALGORITHMS_TRANSPOSE_HXX