diff options
author | Patrick Simianer <p@simianer.de> | 2014-07-09 15:26:00 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-07-09 15:26:00 +0200 |
commit | 567f2bd17c05d31cd8a9b9d351f9030cddf53cb7 (patch) | |
tree | 390d1c28de381849ae9331b433695f5fb389d440 /fast/semiring.hh | |
parent | a3f9fb73ffe4f942851ff496a72ca2445ffd9e0a (diff) |
c++ implementation
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 + |