summaryrefslogtreecommitdiff
path: root/gi/pyp-topics/src/pyp-topics.cc
diff options
context:
space:
mode:
authorbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-05 22:23:18 +0000
committerbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-05 22:23:18 +0000
commit11deae81f9c6bf8f85a29dfdf8b1531d7c563ef8 (patch)
tree64b0f332a756071c883e85b58c2f7495743f91e0 /gi/pyp-topics/src/pyp-topics.cc
parent3f184d8e18dbe5bb6b25f8bb4bd4d00fafb6ef40 (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
Diffstat (limited to 'gi/pyp-topics/src/pyp-topics.cc')
-rw-r--r--gi/pyp-topics/src/pyp-topics.cc10
1 files changed, 8 insertions, 2 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();