diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-11-15 17:07:04 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-11-15 17:07:04 +0000 |
commit | 19840a3f47d64c38753c1fac46cb4f39212fc99f (patch) | |
tree | abc060aa8008b43cc15d331f80fa9ecfa48d778c /training/em_utils.h | |
parent | 49fb41843a2ad81e3ef2b65e5b9264809aac1847 (diff) |
model 1 options
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@723 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'training/em_utils.h')
-rw-r--r-- | training/em_utils.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/training/em_utils.h b/training/em_utils.h new file mode 100644 index 00000000..37762978 --- /dev/null +++ b/training/em_utils.h @@ -0,0 +1,24 @@ +#ifndef _EM_UTILS_H_ +#define _EM_UTILS_H_ + +#include "config.h" +#ifdef HAVE_BOOST_DIGAMMA +#include <boost/math/special_functions/digamma.hpp> +using boost::math::digamma; +#else +#warning Using Mark Johnsons digamma() +#include <cmath> +inline double digamma(double x) { + double result = 0, xx, xx2, xx4; + assert(x > 0); + for ( ; x < 7; ++x) + result -= 1/x; + x -= 1.0/2.0; + xx = 1.0/x; + xx2 = xx*xx; + xx4 = xx2*xx2; + result += log(x)+(1./24.)*xx2-(7.0/960.0)*xx4+(31.0/8064.0)*xx4*xx2-(127.0/30720.0)*xx4*xx4; + return result; +} +#endif +#endif |