Vaucanson  1.4.1
implementation/semiring/tropical_semiring.hh
1 // tropical_semiring.hh: 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, 2007, 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_ALGEBRA_IMPLEMENTATION_SEMIRING_TROPICAL_SEMIRING_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_TROPICAL_SEMIRING_HH
19 
20 # include <vaucanson/algebra/concept/tropical_semiring.hh>
21 
22 namespace vcsn {
23 
24  namespace algebra {
25 
26  // We provide a generic implementation of tropical semirings
27  // formed with C++-builtins and standard operations (std::min,
28  // std::max, +).
29 
30  /*---------------.
31  | Identity value |
32  `---------------*/
33  template<class TropicalKind, typename T>
34  T identity_value(SELECTOR(algebra::TropicalSemiring<TropicalKind>),
35  SELECTOR(T));
36 
37  template<class TropicalKind, typename T>
38  bool show_identity_value(SELECTOR(algebra::TropicalSemiring<TropicalKind>),
39  SELECTOR(T));
40 
41 
42  template<typename T>
43  T zero_value(SELECTOR(algebra::TropicalSemiring<algebra::TropicalMax>),
44  SELECTOR(T));
45 
46  template<typename T>
47  T zero_value(SELECTOR(algebra::TropicalSemiring<algebra::TropicalMin>),
48  SELECTOR(T));
49 
50  /*------------.
51  | op_contains |
52  `------------*/
53  template<class TropicalKind, typename T>
54  bool op_contains(const algebra::TropicalSemiring<TropicalKind>& s, T c);
55 
56  /*--------------------.
57  | Multiplication is + |
58  `--------------------*/
59  template<class TropicalKind, typename T, typename U>
60  void op_in_mul(const algebra::TropicalSemiring<TropicalKind>& s1,
61  T& dst, U arg);
62 
63  template<class TropicalKind, typename T, typename U>
64  T op_mul(const algebra::TropicalSemiring<TropicalKind>& s, T a, U b);
65 
66  /*---------.
67  | Addition |
68  `---------*/
69  template<typename T, typename U>
70  void op_in_add(const algebra::TropicalSemiring<algebra::TropicalMax>& s1,
71  T& dst, U arg);
72 
73  template<typename T, typename U>
74  void op_in_add(const algebra::TropicalSemiring<algebra::TropicalMin>& s1,
75  T& dst, U arg);
76 
77  template<typename T, typename U>
78  T op_add(const algebra::TropicalSemiring<algebra::TropicalMax>& s,
79  T a, U b);
80 
81  template<typename T, typename U>
82  T op_add(const algebra::TropicalSemiring<algebra::TropicalMin>& s,
83  T a, U b);
84 
85  /*-----.
86  | Star |
87  `-----*/
88  template <typename T>
89  bool
90  op_starable(const algebra::TropicalSemiring<algebra::TropicalMin>&, T b);
91 
92  template <class T>
93  void
94  op_in_star(const algebra::TropicalSemiring<algebra::TropicalMin>& s, T& b);
95 
96  template <typename T>
97  bool
98  op_starable(const algebra::TropicalSemiring<algebra::TropicalMax>&, T b);
99 
100  template <class T>
101  void
102  op_in_star(const algebra::TropicalSemiring<algebra::TropicalMax>&, T& b);
103 
104  template <class TropicalKind, class T>
105  Element<algebra::TropicalSemiring<TropicalKind>, T>
106  op_choose(const algebra::TropicalSemiring<TropicalKind>& set, SELECTOR(T));
107 
108  template <class TropicalKind, typename T>
109  bool
110  op_can_choose_non_starable(const algebra::TropicalSemiring<TropicalKind>&
111  set, SELECTOR(T));
112 
113  template <class TropicalKind, typename T>
114  Element<algebra::TropicalSemiring<TropicalKind>, T>
115  op_choose_starable(const algebra::TropicalSemiring<TropicalKind>& set,
116  SELECTOR(T));
117 
118  template <class TropicalKind, typename T>
119  Element<algebra::TropicalSemiring<TropicalKind>, T>
120  op_choose_non_starable(const algebra::TropicalSemiring<TropicalKind>& set,
121  SELECTOR(T));
122 
123  /*---------------.
124  | Pretty printer |
125  `---------------*/
126  template<typename St, typename T>
127  St& op_rout(const algebra::TropicalSemiring<algebra::TropicalMax>& s,
128  St& st, const T& v);
129 
130  template<typename St, typename T>
131  St& op_rout(const algebra::TropicalSemiring<algebra::TropicalMin>& s,
132  St& st, const T& v);
133 
134  } // algebra
135 
136  template<class TropicalKind, typename T>
137  struct semiring_traits<algebra::TropicalSemiring<TropicalKind>, T>
138  {
139  enum { is_positive = 1 };
140  };
141 
142 
143 } // vcsn
144 
145 
146 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
147 # include <vaucanson/algebra/implementation/semiring/tropical_semiring.hxx>
148 # endif // VCSN_USE_INTERFACE_ONLY
149 
150 
151 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_TROPICAL_SEMIRING_HH