summaryrefslogtreecommitdiff
path: root/fast/semiring.hh
blob: 1c3ff1dbb93e4a167d76fa82c717b60455d0aa8c (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
#pragma once


// TODO: others
namespace Semiring {

template<typename T>
struct Viterbi {
  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
Viterbi<T>::add(T x, T y)
{
  return max(x, y);
}

template<typename T> T
Viterbi<T>::multiply(T x, T y)
{
  return x * y;
}

template<typename T> T
Viterbi<T>::convert(T x)
{
  return (T)x;
}

} // namespace