Vaucanson  1.4.1
is_normalized.hxx
1 // is_normalized.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 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_IS_NORMALIZED_HXX
18 # define VCSN_ALGORITHMS_IS_NORMALIZED_HXX
19 
21 # include <vaucanson/automata/concept/automata_base.hh>
22 # include <vaucanson/misc/usual_macros.hh>
23 
24 namespace vcsn {
25 
26  template<typename S, typename A>
27  bool
28  do_is_normalized_transducer(const AutomataBase<S>& trans_set,
29  const A& trans)
30  {
31  AUTOMATON_TYPES(A);
32  bool is_normalized = false;
33  for_all_const_transitions(e, trans)
34  {
35  is_normalized ^= is_support_in_alphabet(trans.series_of(*e));
36  for_all_const_(series_set_elt_t::support_t,
37  i,
38  trans.series_of(*e).supp())
39  {
40  is_normalized ^= is_support_in_alphabet(trans.series_of(*e).get(*i));
41  if (!is_normalized)
42  return false;
43  }
44  }
45  return true;
46  }
47 
48  template<typename S, typename A>
49  bool
51  {
52  BENCH_TASK_SCOPED("is_normalized_transducer");
53  return do_is_normalized_transducer(a.structure(), a);
54  }
55 }
56 
57 #endif // ! VCSN_ALGORITHMS_IS_NORMALIZED_HXX