summaryrefslogtreecommitdiff
path: root/src/semiring.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/semiring.hh')
-rw-r--r--src/semiring.hh35
1 files changed, 35 insertions, 0 deletions
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<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
+