vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp in tomoto-0.1.4 vs vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp in tomoto-0.2.0

- old
+ new

@@ -83,19 +83,19 @@ static constexpr const char TWID[] = "one\0"; static constexpr static constexpr char TMID[] = "LDA\0"; Float alpha; - Eigen::Matrix<Float, -1, 1> alphas; + Vector alphas; Float eta; Tid K; size_t optimInterval = 50; template<typename _List> static Float calcDigammaSum(_List list, size_t len, Float alpha) { - auto listExpr = Eigen::Matrix<Float, -1, 1>::NullaryExpr(len, list); + auto listExpr = Vector::NullaryExpr(len, list); auto dAlpha = math::digammaT(alpha); return (math::digammaApprox(listExpr.array() + alpha) - dAlpha).sum(); } void optimizeParameters(ThreadPool& pool, _ModelState* localData) @@ -263,15 +263,15 @@ } void initGlobalState(bool initDocs) { const size_t V = this->realV; - this->globalState.zLikelihood = Eigen::Matrix<Float, -1, 1>::Zero(K); + this->globalState.zLikelihood = Vector::Zero(K); if (initDocs) { - this->globalState.numByTopic = Eigen::Matrix<Float, -1, 1>::Zero(K); - this->globalState.numByTopicWord = Eigen::Matrix<Float, -1, -1>::Zero(K, V); + this->globalState.numByTopic = Vector::Zero(K); + this->globalState.numByTopicWord = Matrix::Zero(K, V); } } struct Generator { @@ -333,11 +333,11 @@ public: LDACVB0Model(size_t _K = 1, Float _alpha = 0.1, Float _eta = 0.01, size_t _rg = std::random_device{}()) : BaseClass(_rg), K(_K), alpha(_alpha), eta(_eta) { - alphas = Eigen::Matrix<Float, -1, 1>::Constant(K, alpha); + alphas = Vector::Constant(K, alpha); } GETTER(K, size_t, K); GETTER(Alpha, Float, alpha); GETTER(Eta, Float, eta); GETTER(OptimInterval, size_t, optimInterval); @@ -353,11 +353,11 @@ return this->_addDoc(this->_makeDoc(words)); } std::unique_ptr<DocumentBase> makeDoc(const std::vector<std::string>& words) const override { - return make_unique<_DocType>(as_mutable(this)->template _makeDoc<true>(words)); + return std::make_unique<_DocType>(as_mutable(this)->template _makeDoc<true>(words)); } void updateDocs() { for (auto& doc : this->docs) @@ -401,10 +401,10 @@ return (n + alpha) / sum; }); return ret; } - std::vector<Float> _getWidsByTopic(Tid tid) const + std::vector<Float> _getWidsByTopic(Tid tid, bool normalize = true) const { assert(tid < K); const size_t V = this->realV; std::vector<Float> ret(V); Float sum = this->globalState.numByTopic[tid] + V * eta; \ No newline at end of file