From 567f2bd17c05d31cd8a9b9d351f9030cddf53cb7 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 9 Jul 2014 15:26:00 +0200 Subject: c++ implementation --- fast/semiring.hh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 fast/semiring.hh (limited to 'fast/semiring.hh') 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 +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 T +ViterbiSemiring::add(T x, T y) +{ + return max(x, y); +} + +template T +ViterbiSemiring::multiply(T x, T y) +{ + return x * y; +} + +template T +ViterbiSemiring::convert(T x) +{ + return (T)x; +} + + +#endif + -- cgit v1.2.3