diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-10-22 12:07:20 +0100 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-10-22 12:07:20 +0100 |
commit | 5f98fe5c4f2a2090eeb9d30c030305a70a8347d1 (patch) | |
tree | 9b6002f850e6dea1e3400c6b19bb31a9cdf3067f /rst_parser/arc_factored_marginals.cc | |
parent | cf9994131993b40be62e90e213b1e11e6b550143 (diff) | |
parent | 21825a09d97c2e0afd20512f306fb25fed55e529 (diff) |
Merge remote branch 'upstream/master'
Conflicts:
Jamroot
bjam
decoder/Jamfile
decoder/cdec.cc
dpmert/Jamfile
jam-files/sanity.jam
klm/lm/Jamfile
klm/util/Jamfile
mira/Jamfile
Diffstat (limited to 'rst_parser/arc_factored_marginals.cc')
-rw-r--r-- | rst_parser/arc_factored_marginals.cc | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/rst_parser/arc_factored_marginals.cc b/rst_parser/arc_factored_marginals.cc deleted file mode 100644 index 3e8c9f86..00000000 --- a/rst_parser/arc_factored_marginals.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include "arc_factored.h" - -#include <iostream> - -#include "config.h" - -using namespace std; - -#if HAVE_EIGEN - -#include <Eigen/Dense> -typedef Eigen::Matrix<prob_t, Eigen::Dynamic, Eigen::Dynamic> ArcMatrix; -typedef Eigen::Matrix<prob_t, Eigen::Dynamic, 1> RootVector; - -void ArcFactoredForest::EdgeMarginals(prob_t *plog_z) { - ArcMatrix A(num_words_,num_words_); - RootVector r(num_words_); - for (int h = 0; h < num_words_; ++h) { - for (int m = 0; m < num_words_; ++m) { - if (h != m) - A(h,m) = edges_(h,m).edge_prob; - else - A(h,m) = prob_t::Zero(); - } - r(h) = root_edges_[h].edge_prob; - } - - ArcMatrix L = -A; - L.diagonal() = A.colwise().sum(); - L.row(0) = r; - ArcMatrix Linv = L.inverse(); - if (plog_z) *plog_z = Linv.determinant(); - RootVector rootMarginals = r.cwiseProduct(Linv.col(0)); - static const prob_t ZERO(0); - static const prob_t ONE(1); -// ArcMatrix T = Linv; - for (int h = 0; h < num_words_; ++h) { - for (int m = 0; m < num_words_; ++m) { - const prob_t marginal = (m == 0 ? ZERO : ONE) * A(h,m) * Linv(m,m) - - (h == 0 ? ZERO : ONE) * A(h,m) * Linv(m,h); - edges_(h,m).edge_prob = marginal; -// T(h,m) = marginal; - } - root_edges_[h].edge_prob = rootMarginals(h); - } -// cerr << "ROOT MARGINALS: " << rootMarginals.transpose() << endl; -// cerr << "M:\n" << T << endl; -} - -#else - -void ArcFactoredForest::EdgeMarginals(prob_t *) { - cerr << "EdgeMarginals() requires --with-eigen!\n"; - abort(); -} - -#endif - |