summaryrefslogtreecommitdiff
path: root/src/semiring.hh
blob: 3f4ac0806f12d44b2c63f91d84b8ed8b26a7bf3a (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
#pragma once


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