Awali
Another Weighted Automata library
gf2.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_WEIGHTSET_GF2_HH
18 # define AWALI_WEIGHTSET_GF2_HH
19 
20 # include <cassert>
21 # include <ostream>
22 
24 #include <awali/utils/hash.hh>
25 #include <awali/sttc/misc/raise.hh>
26 #include <awali/common/enums.hh>
29 
30 namespace awali { namespace sttc {
31 
32  namespace internal
33  {
34  class gf2_impl
35  {
36  public:
37  using self_type = gf2;
38 
39  static std::string sname()
40  {
41  return "gf2";
42  }
43 
44  std::string vname(bool = true) const
45  {
46  return sname();
47  }
48 
49  enum gf2_value {
50  Z, O, X, X_O, X2, X2_O, X2_X, X2_X_O
51  }
52 
53  gf2_value[8][8] addition_table = {
54  // 0 1 x x+1 x² x²+1 x²+x x²+x+1
55  { Z, O, X, X_O, X2, X2_O, X2_X, X2_X_O } // +0
56  { O, Z, X_O, X, X2_O, X2, X2_X_O, X2_X } // +1
57  { X, X_O, Z, O, X2_X, X2_X_O, X2, X2_O } // +x
58  { X_O, X, O, Z, X2_X_O, X2_X, X2_O, X2 } // +x+1
59  { X2, X2_O, X2_X, X2_X_O, Z, O, X, X_O } // +x²
60  { X2_O, X2, X2_X_O, X2_X, O, Z, X_O, X } // +x²+1
61  { X2_X, X2_X_O, X2, X2_O, X, X_O, Z, O } // +x²+x
62  { X2_X_O, X2_X, X2_O, X2, X_O, X, O, Z } // +x²+x+1
63  };
64 
65  using value_t = gf2_value;
66  };
67  }
68 }}//end of ns awali::stc
Definition: gf2.hh:35
enum awali::sttc::internal::gf2_impl::gf2_value addition_table[8][8]
gf2_value
Definition: gf2.hh:49
@ X2
Definition: gf2.hh:50
@ X2_O
Definition: gf2.hh:50
@ X
Definition: gf2.hh:50
@ Z
Definition: gf2.hh:50
@ X2_X_O
Definition: gf2.hh:50
@ X2_X
Definition: gf2.hh:50
@ X_O
Definition: gf2.hh:50
@ O
Definition: gf2.hh:50
std::string vname(bool=true) const
Definition: gf2.hh:44
static std::string sname()
Definition: gf2.hh:39
gf2 self_type
Definition: gf2.hh:37
Main namespace of Awali.
Definition: ato.hh:22