From 129a22cfcc7651daa4b11ed52e7870249f6373a5 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 16 Sep 2014 10:23:14 +0100 Subject: spring cleaning --- src/semiring.hh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/semiring.hh (limited to 'src/semiring.hh') diff --git a/src/semiring.hh b/src/semiring.hh new file mode 100644 index 0000000..3f4ac08 --- /dev/null +++ b/src/semiring.hh @@ -0,0 +1,35 @@ +#pragma once + + +namespace Semiring { + +template +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 T +Viterbi::add(T x, T y) +{ + return max(x, y); +} + +template T +Viterbi::multiply(T x, T y) +{ + return x * y; +} + +template T +Viterbi::convert(T x) +{ + return (T)x; +} + +} // namespace + -- cgit v1.2.3