Sha256: e44e123f7b7100567e374f2f7e255b5b407b3fe7da1ed94e24e188ab87d4df6e

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

#include <HDP.h>

#include <rice/Module.hpp>

#include "utils.h"

void init_hdp(Rice::Module& m) {
  Rice::define_class_under<tomoto::IHDPModel, tomoto::ILDAModel>(m, "HDP")
    .define_singleton_method(
      "_new",
      *[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma, int seed) {
        if (seed < 0) {
          seed = std::random_device{}();
        }
        return tomoto::IHDPModel::create((tomoto::TermWeight)tw, k, alpha, eta, gamma, seed);
      })
    .define_method(
      "alpha",
      *[](tomoto::IHDPModel& self) {
        return self.getAlpha();
      })
    .define_method(
      "gamma",
      *[](tomoto::IHDPModel& self) {
        return self.getGamma();
      })
    .define_method(
      "live_k",
      *[](tomoto::IHDPModel& self) {
        return self.getLiveK();
      })
    .define_method(
      "live_topic?",
      *[](tomoto::IHDPModel& self, size_t tid) {
        return self.isLiveTopic(tid);
      })
    .define_method(
      "num_tables",
      *[](tomoto::IHDPModel& self) {
        return self.getTotalTables();
      });
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tomoto-0.1.4 ext/tomoto/hdp.cpp