diff options
Diffstat (limited to 'fast/semiring.hh')
-rw-r--r-- | fast/semiring.hh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fast/semiring.hh b/fast/semiring.hh new file mode 100644 index 0000000..1e40f48 --- /dev/null +++ b/fast/semiring.hh @@ -0,0 +1,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 + |