diff options
author | bothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-05 22:23:18 +0000 |
---|---|---|
committer | bothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-05 22:23:18 +0000 |
commit | f417aa33ee1e1ff2a301128ed08aa9dba7c2ff6b (patch) | |
tree | e8bb127043d5a2214b6525465e7e8bc399379173 | |
parent | 6dab4e812254c94d1736e7755df410556ce5b751 (diff) |
restaurant instances are now kept in ptr_vectors instead of standard vectors; avoids copy constructing of those instances, which creates problems when including Boost's RNG objects as members in a restaurant.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@145 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r-- | gi/pyp-topics/src/pyp-topics.cc | 10 | ||||
-rw-r--r-- | gi/pyp-topics/src/pyp-topics.hh | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gi/pyp-topics/src/pyp-topics.cc b/gi/pyp-topics/src/pyp-topics.cc index 0ac1b709..2ad9d080 100644 --- a/gi/pyp-topics/src/pyp-topics.cc +++ b/gi/pyp-topics/src/pyp-topics.cc @@ -43,10 +43,16 @@ void PYPTopics::sample_corpus(const Corpus& corpus, int samples, << (m_word_pyps.size()==2 ? ":" : "s:") << std::endl; for (int i=0; i<(int)m_word_pyps.size(); ++i) - m_word_pyps.at(i).resize(m_num_topics, PYP<int>(0.5, 1.0)); + { + m_word_pyps.at(i).reserve(m_num_topics); + for (int j=0; j<m_num_topics; ++j) + m_word_pyps.at(i).push_back(new PYP<int>(0.5, 1.0)); + } std::cerr << std::endl; - m_document_pyps.resize(corpus.num_documents(), PYP<int>(0.5, 1.0)); + m_document_pyps.reserve(corpus.num_documents()); + for (int j=0; j<corpus.num_documents(); ++j) + m_document_pyps.push_back(new PYP<int>(0.5, 1.0)); m_topic_p0 = 1.0/m_num_topics; m_term_p0 = 1.0/corpus.num_types(); diff --git a/gi/pyp-topics/src/pyp-topics.hh b/gi/pyp-topics/src/pyp-topics.hh index d4d87440..996ef4dd 100644 --- a/gi/pyp-topics/src/pyp-topics.hh +++ b/gi/pyp-topics/src/pyp-topics.hh @@ -3,7 +3,7 @@ #include <vector> #include <iostream> - +#include <boost/ptr_container/ptr_vector.hpp> #include "pyp.hh" #include "corpus.hh" @@ -54,7 +54,7 @@ private: F m_term_p0, m_topic_p0, m_backoff_p0; CorpusTopics m_corpus_topics; - typedef std::vector< PYP<int> > PYPs; + typedef boost::ptr_vector< PYP<int> > PYPs; PYPs m_document_pyps; std::vector<PYPs> m_word_pyps; PYP<int> m_topic_pyp; |