blob: 1e40f48c038e730c9ccc20701f661f1ae066c5b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#ifndef SEMIRING_HH
#define SEMIRING_HH
template<typename T>
class ViterbiSemiring {
public:
T one = 1.0;
T null = 0.0;
T add(T x, T y);
T multiply(T x, T y);
T convert(T x);
};
template<typename T> T
ViterbiSemiring<T>::add(T x, T y)
{
return max(x, y);
}
template<typename T> T
ViterbiSemiring<T>::multiply(T x, T y)
{
return x * y;
}
template<typename T> T
ViterbiSemiring<T>::convert(T x)
{
return (T)x;
}
#endif
|