tomoto 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE.txt +1 -1
  4. data/ext/tomoto/ct.cpp +1 -1
  5. data/ext/tomoto/dmr.cpp +1 -1
  6. data/ext/tomoto/dt.cpp +1 -1
  7. data/ext/tomoto/extconf.rb +4 -8
  8. data/ext/tomoto/gdmr.cpp +1 -1
  9. data/ext/tomoto/hdp.cpp +1 -1
  10. data/ext/tomoto/hlda.cpp +1 -1
  11. data/ext/tomoto/hpa.cpp +1 -1
  12. data/ext/tomoto/lda.cpp +29 -3
  13. data/ext/tomoto/llda.cpp +1 -1
  14. data/ext/tomoto/mglda.cpp +1 -1
  15. data/ext/tomoto/pa.cpp +1 -1
  16. data/ext/tomoto/plda.cpp +1 -1
  17. data/ext/tomoto/slda.cpp +1 -1
  18. data/lib/tomoto/lda.rb +1 -0
  19. data/lib/tomoto/version.rb +1 -1
  20. data/vendor/EigenRand/EigenRand/Core.h +6 -4
  21. data/vendor/EigenRand/EigenRand/CwiseHeteroBinaryOp.h +265 -0
  22. data/vendor/EigenRand/EigenRand/Dists/Basic.h +345 -12
  23. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +381 -7
  24. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +4 -4
  25. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +576 -4
  26. data/vendor/EigenRand/EigenRand/EigenRand +4 -4
  27. data/vendor/EigenRand/EigenRand/Macro.h +3 -3
  28. data/vendor/EigenRand/EigenRand/MorePacketMath.h +31 -30
  29. data/vendor/EigenRand/EigenRand/MvDists/Multinomial.h +41 -29
  30. data/vendor/EigenRand/EigenRand/MvDists/MvNormal.h +19 -7
  31. data/vendor/EigenRand/EigenRand/PacketFilter.h +8 -5
  32. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +3 -3
  33. data/vendor/EigenRand/EigenRand/RandUtils.h +180 -5
  34. data/vendor/EigenRand/EigenRand/arch/AVX/MorePacketMath.h +42 -3
  35. data/vendor/EigenRand/EigenRand/arch/AVX/PacketFilter.h +3 -3
  36. data/vendor/EigenRand/EigenRand/arch/AVX/RandUtils.h +3 -3
  37. data/vendor/EigenRand/EigenRand/arch/AVX512/MorePacketMath.h +312 -0
  38. data/vendor/EigenRand/EigenRand/arch/AVX512/PacketFilter.h +79 -0
  39. data/vendor/EigenRand/EigenRand/arch/AVX512/RandUtils.h +147 -0
  40. data/vendor/EigenRand/EigenRand/arch/NEON/MorePacketMath.h +118 -3
  41. data/vendor/EigenRand/EigenRand/arch/NEON/PacketFilter.h +3 -3
  42. data/vendor/EigenRand/EigenRand/arch/NEON/RandUtils.h +21 -3
  43. data/vendor/EigenRand/EigenRand/arch/SSE/MorePacketMath.h +32 -4
  44. data/vendor/EigenRand/EigenRand/arch/SSE/PacketFilter.h +3 -3
  45. data/vendor/EigenRand/EigenRand/arch/SSE/RandUtils.h +3 -3
  46. data/vendor/EigenRand/EigenRand/doc.h +108 -157
  47. data/vendor/EigenRand/README.md +60 -272
  48. data/vendor/tomotopy/README.kr.rst +27 -5
  49. data/vendor/tomotopy/README.rst +27 -5
  50. data/vendor/tomotopy/README_pypi.rst +583 -0
  51. data/vendor/tomotopy/licenses_bundled/EigenRand +21 -0
  52. data/vendor/tomotopy/src/TopicModel/CT.h +1 -1
  53. data/vendor/tomotopy/src/TopicModel/CTModel.cpp +1 -1
  54. data/vendor/tomotopy/src/TopicModel/DMR.h +1 -1
  55. data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +1 -1
  56. data/vendor/tomotopy/src/TopicModel/DT.h +1 -1
  57. data/vendor/tomotopy/src/TopicModel/DTModel.cpp +1 -1
  58. data/vendor/tomotopy/src/TopicModel/GDMR.h +1 -1
  59. data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +1 -1
  60. data/vendor/tomotopy/src/TopicModel/HDP.h +1 -1
  61. data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +1 -1
  62. data/vendor/tomotopy/src/TopicModel/HLDA.h +1 -1
  63. data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +1 -1
  64. data/vendor/tomotopy/src/TopicModel/HPA.h +1 -1
  65. data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +1 -1
  66. data/vendor/tomotopy/src/TopicModel/LDA.h +1 -1
  67. data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +1 -1
  68. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +6 -6
  69. data/vendor/tomotopy/src/TopicModel/LLDA.h +1 -1
  70. data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +1 -1
  71. data/vendor/tomotopy/src/TopicModel/MGLDA.h +1 -1
  72. data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +1 -1
  73. data/vendor/tomotopy/src/TopicModel/PA.h +1 -1
  74. data/vendor/tomotopy/src/TopicModel/PAModel.cpp +1 -1
  75. data/vendor/tomotopy/src/TopicModel/PLDA.h +1 -1
  76. data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +1 -1
  77. data/vendor/tomotopy/src/TopicModel/PT.h +1 -1
  78. data/vendor/tomotopy/src/TopicModel/PTModel.cpp +1 -1
  79. data/vendor/tomotopy/src/TopicModel/SLDA.h +1 -1
  80. data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +1 -1
  81. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +6 -6
  82. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +41 -0
  83. data/vendor/tomotopy/src/Utils/ThreadPool.hpp +6 -6
  84. data/vendor/tomotopy/src/Utils/Utils.hpp +3 -3
  85. data/vendor/tomotopy/src/Utils/avx512_gamma.h +46 -0
  86. data/vendor/tomotopy/src/Utils/avx512_mathfun.h +99 -0
  87. metadata +10 -9
  88. data/vendor/variant/LICENSE +0 -25
  89. data/vendor/variant/LICENSE_1_0.txt +0 -23
  90. data/vendor/variant/README.md +0 -102
  91. data/vendor/variant/include/mapbox/optional.hpp +0 -74
  92. data/vendor/variant/include/mapbox/recursive_wrapper.hpp +0 -122
  93. data/vendor/variant/include/mapbox/variant.hpp +0 -974
  94. data/vendor/variant/include/mapbox/variant_io.hpp +0 -45
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentGDMR);
9
9
 
10
- IGDMRModel* IGDMRModel::create(TermWeight _weight, const GDMRArgs& args, bool scalarRng)
10
+ std::unique_ptr<IGDMRModel> IGDMRModel::create(TermWeight _weight, const GDMRArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, GDMRModel, args);
13
13
  }
@@ -70,7 +70,7 @@ namespace tomoto
70
70
  {
71
71
  public:
72
72
  using DefaultDocType = DocumentHDP<TermWeight::one>;
73
- static IHDPModel* create(TermWeight _weight, const HDPArgs& args,
73
+ static std::unique_ptr<IHDPModel> create(TermWeight _weight, const HDPArgs& args,
74
74
  bool scalarRng = false);
75
75
 
76
76
  virtual Float getGamma() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentHDP);
9
9
 
10
- IHDPModel* IHDPModel::create(TermWeight _weight, const HDPArgs& args, bool scalarRng)
10
+ std::unique_ptr<IHDPModel> IHDPModel::create(TermWeight _weight, const HDPArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, HDPModel, args);
13
13
  }
@@ -34,7 +34,7 @@ namespace tomoto
34
34
  {
35
35
  public:
36
36
  using DefaultDocType = DocumentHLDA<TermWeight::one>;
37
- static IHLDAModel* create(TermWeight _weight, const HLDAArgs& args,
37
+ static std::unique_ptr<IHLDAModel> create(TermWeight _weight, const HLDAArgs& args,
38
38
  bool scalarRng = false);
39
39
 
40
40
  virtual Float getGamma() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentHLDA);
9
9
 
10
- IHLDAModel* IHLDAModel::create(TermWeight _weight, const HLDAArgs& args, bool scalarRng)
10
+ std::unique_ptr<IHLDAModel> IHLDAModel::create(TermWeight _weight, const HLDAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, HLDAModel, args);
13
13
  }
@@ -24,7 +24,7 @@ namespace tomoto
24
24
  {
25
25
  public:
26
26
  using DefaultDocType = DocumentHPA<TermWeight::one>;
27
- static IHPAModel* create(TermWeight _weight, bool _exclusive, const HPAArgs& args,
27
+ static std::unique_ptr<IHPAModel> create(TermWeight _weight, bool _exclusive, const HPAArgs& args,
28
28
  bool scalarRng = false);
29
29
  };
30
30
  }
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentHPA);
9
9
 
10
- IHPAModel* IHPAModel::create(TermWeight _weight, bool _exclusive, const HPAArgs& args, bool scalarRng)
10
+ std::unique_ptr<IHPAModel> IHPAModel::create(TermWeight _weight, bool _exclusive, const HPAArgs& args, bool scalarRng)
11
11
  {
12
12
  if (_exclusive)
13
13
  {
@@ -179,7 +179,7 @@ namespace tomoto
179
179
  {
180
180
  public:
181
181
  using DefaultDocType = DocumentLDA<TermWeight::one>;
182
- static ILDAModel* create(TermWeight _weight, const LDAArgs& args,
182
+ static std::unique_ptr<ILDAModel> create(TermWeight _weight, const LDAArgs& args,
183
183
  bool scalarRng = false);
184
184
 
185
185
  virtual TermWeight getTermWeight() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentLDA);
9
9
 
10
- ILDAModel* ILDAModel::create(TermWeight _weight, const LDAArgs& args, bool scalarRng)
10
+ std::unique_ptr<ILDAModel> ILDAModel::create(TermWeight _weight, const LDAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, LDAModel, args);
13
13
  }
@@ -24,11 +24,11 @@ Term Weighting Scheme is based on following paper:
24
24
  {\
25
25
  switch (TW){\
26
26
  case TermWeight::one:\
27
- return new MDL<TermWeight::one, ScalarRandGen>(__VA_ARGS__);\
27
+ return std::make_unique<MDL<TermWeight::one, ScalarRandGen>>(__VA_ARGS__);\
28
28
  case TermWeight::idf:\
29
- return new MDL<TermWeight::idf, ScalarRandGen>(__VA_ARGS__);\
29
+ return std::make_unique<MDL<TermWeight::idf, ScalarRandGen>>(__VA_ARGS__);\
30
30
  case TermWeight::pmi:\
31
- return new MDL<TermWeight::pmi, ScalarRandGen>(__VA_ARGS__);\
31
+ return std::make_unique<MDL<TermWeight::pmi, ScalarRandGen>>(__VA_ARGS__);\
32
32
  }\
33
33
  }\
34
34
  return nullptr; } while(0)
@@ -37,11 +37,11 @@ Term Weighting Scheme is based on following paper:
37
37
  {\
38
38
  switch (TW){\
39
39
  case TermWeight::one:\
40
- return new MDL<TermWeight::one, RandGen>(__VA_ARGS__);\
40
+ return std::make_unique<MDL<TermWeight::one, RandGen>>(__VA_ARGS__);\
41
41
  case TermWeight::idf:\
42
- return new MDL<TermWeight::idf, RandGen>(__VA_ARGS__);\
42
+ return std::make_unique<MDL<TermWeight::idf, RandGen>>(__VA_ARGS__);\
43
43
  case TermWeight::pmi:\
44
- return new MDL<TermWeight::pmi, RandGen>(__VA_ARGS__);\
44
+ return std::make_unique<MDL<TermWeight::pmi, RandGen>>(__VA_ARGS__);\
45
45
  }\
46
46
  }\
47
47
  return nullptr; } while(0)
@@ -19,7 +19,7 @@ namespace tomoto
19
19
  {
20
20
  public:
21
21
  using DefaultDocType = DocumentLLDA<TermWeight::one>;
22
- static ILLDAModel* create(TermWeight _weight, const LDAArgs& args,
22
+ static std::unique_ptr<ILLDAModel> create(TermWeight _weight, const LDAArgs& args,
23
23
  bool scalarRng = false);
24
24
 
25
25
  virtual const Dictionary& getTopicLabelDict() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentLLDA);
9
9
 
10
- ILLDAModel* ILLDAModel::create(TermWeight _weight, const LDAArgs& args, bool scalarRng)
10
+ std::unique_ptr<ILLDAModel> ILLDAModel::create(TermWeight _weight, const LDAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, LLDAModel, args);
13
13
  }
@@ -43,7 +43,7 @@ namespace tomoto
43
43
  {
44
44
  public:
45
45
  using DefaultDocType = DocumentMGLDA<TermWeight::one>;
46
- static IMGLDAModel* create(TermWeight _weight, const MGLDAArgs& args,
46
+ static std::unique_ptr<IMGLDAModel> create(TermWeight _weight, const MGLDAArgs& args,
47
47
  bool scalarRng = false);
48
48
 
49
49
  virtual size_t getKL() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentMGLDA);
9
9
 
10
- IMGLDAModel* IMGLDAModel::create(TermWeight _weight, const MGLDAArgs& args, bool scalarRng)
10
+ std::unique_ptr<IMGLDAModel> IMGLDAModel::create(TermWeight _weight, const MGLDAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, MGLDAModel, args);
13
13
  }
@@ -29,7 +29,7 @@ namespace tomoto
29
29
  {
30
30
  public:
31
31
  using DefaultDocType = DocumentPA<TermWeight::one>;
32
- static IPAModel* create(TermWeight _weight, const PAArgs& args,
32
+ static std::unique_ptr<IPAModel> create(TermWeight _weight, const PAArgs& args,
33
33
  bool scalarRng = false);
34
34
 
35
35
  virtual size_t getDirichletEstIteration() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentPA);
9
9
 
10
- IPAModel* IPAModel::create(TermWeight _weight, const PAArgs& args, bool scalarRng)
10
+ std::unique_ptr<IPAModel> IPAModel::create(TermWeight _weight, const PAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, PAModel, args);
13
13
  }
@@ -20,7 +20,7 @@ namespace tomoto
20
20
  {
21
21
  public:
22
22
  using DefaultDocType = DocumentLLDA<TermWeight::one>;
23
- static IPLDAModel* create(TermWeight _weight, const PLDAArgs& args,
23
+ static std::unique_ptr<IPLDAModel> create(TermWeight _weight, const PLDAArgs& args,
24
24
  bool scalarRng = false);
25
25
 
26
26
  virtual size_t getNumLatentTopics() const = 0;
@@ -2,7 +2,7 @@
2
2
 
3
3
  namespace tomoto
4
4
  {
5
- IPLDAModel* IPLDAModel::create(TermWeight _weight, const PLDAArgs& args, bool scalarRng)
5
+ std::unique_ptr<IPLDAModel> IPLDAModel::create(TermWeight _weight, const PLDAArgs& args, bool scalarRng)
6
6
  {
7
7
  TMT_SWITCH_TW(_weight, scalarRng, PLDAModel, args);
8
8
  }
@@ -26,7 +26,7 @@ namespace tomoto
26
26
  {
27
27
  public:
28
28
  using DefaultDocType = DocumentPT<TermWeight::one>;
29
- static IPTModel* create(TermWeight _weight, const PTArgs& args,
29
+ static std::unique_ptr<IPTModel> create(TermWeight _weight, const PTArgs& args,
30
30
  bool scalarRng = false);
31
31
 
32
32
  virtual size_t getP() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentPT);
9
9
 
10
- IPTModel* IPTModel::create(TermWeight _weight, const PTArgs& args, bool scalarRng)
10
+ std::unique_ptr<IPTModel> IPTModel::create(TermWeight _weight, const PTArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, PTModel, args);
13
13
  }
@@ -33,7 +33,7 @@ namespace tomoto
33
33
  };
34
34
 
35
35
  using DefaultDocType = DocumentSLDA<TermWeight::one>;
36
- static ISLDAModel* create(TermWeight _weight, const SLDAArgs& args,
36
+ static std::unique_ptr<ISLDAModel> create(TermWeight _weight, const SLDAArgs& args,
37
37
  bool scalarRng = false);
38
38
 
39
39
  virtual size_t getF() const = 0;
@@ -7,7 +7,7 @@ namespace tomoto
7
7
 
8
8
  TMT_INSTANTIATE_DOC(DocumentSLDA);
9
9
 
10
- ISLDAModel* ISLDAModel::create(TermWeight _weight, const SLDAArgs& args, bool scalarRng)
10
+ std::unique_ptr<ISLDAModel> ISLDAModel::create(TermWeight _weight, const SLDAArgs& args, bool scalarRng)
11
11
  {
12
12
  TMT_SWITCH_TW(_weight, scalarRng, SLDAModel, args);
13
13
  }
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
  #include <numeric>
3
3
  #include <unordered_set>
4
+ #include <variant>
4
5
  #include "../Utils/Utils.hpp"
5
6
  #include "../Utils/Dictionary.h"
6
7
  #include "../Utils/tvector.hpp"
@@ -9,7 +10,6 @@
9
10
  #include "../Utils/exception.h"
10
11
  #include "../Utils/SharedString.h"
11
12
  #include <EigenRand/EigenRand>
12
- #include <mapbox/variant.hpp>
13
13
 
14
14
  namespace tomoto
15
15
  {
@@ -38,7 +38,7 @@ namespace tomoto
38
38
 
39
39
  struct RawDoc : public RawDocKernel
40
40
  {
41
- using Var = mapbox::util::variant<
41
+ using Var = std::variant<
42
42
  std::string, uint32_t, Float,
43
43
  std::vector<std::string>, std::vector<uint32_t>, std::vector<Float>,
44
44
  std::shared_ptr<void>
@@ -63,8 +63,8 @@ namespace tomoto
63
63
  {
64
64
  auto it = misc.find(name);
65
65
  if (it == misc.end()) throw exc::InvalidArgument{ "There is no value named `" + name + "` in misc data" };
66
- if (!it->second.template is<_Ty>()) throw exc::InvalidArgument{ "Value named `" + name + "` is not in right type." };
67
- return it->second.template get<_Ty>();
66
+ if (!std::holds_alternative<_Ty>(it->second)) throw exc::InvalidArgument{ "Value named `" + name + "` is not in right type." };
67
+ return std::get<_Ty>(it->second);
68
68
  }
69
69
 
70
70
  template<typename _Ty>
@@ -72,8 +72,8 @@ namespace tomoto
72
72
  {
73
73
  auto it = misc.find(name);
74
74
  if (it == misc.end()) return {};
75
- if (!it->second.template is<_Ty>()) throw exc::InvalidArgument{ "Value named `" + name + "` is not in right type." };
76
- return it->second.template get<_Ty>();
75
+ if (!std::holds_alternative<_Ty>(it->second)) throw exc::InvalidArgument{ "Value named `" + name + "` is not in right type." };
76
+ return std::get<_Ty>(it->second);
77
77
  }
78
78
  };
79
79
 
@@ -56,6 +56,47 @@ namespace Eigen
56
56
  }
57
57
  }
58
58
  #endif
59
+ #ifdef EIGEN_VECTORIZE_AVX512
60
+ #include <immintrin.h>
61
+ #include "avx512_gamma.h"
62
+
63
+ namespace Eigen
64
+ {
65
+ namespace internal
66
+ {
67
+ template<> struct to_int_packet<Packet16f>
68
+ {
69
+ typedef Packet16i type;
70
+ };
71
+
72
+ template<> struct to_float_packet<Packet16i>
73
+ {
74
+ typedef Packet16f type;
75
+ };
76
+
77
+ EIGEN_STRONG_INLINE Packet16f p_to_f32(const Packet16i& a)
78
+ {
79
+ return _mm512_cvtepi32_ps(a);
80
+ }
81
+
82
+ EIGEN_STRONG_INLINE Packet16f p_bool2float(const Packet16f& a)
83
+ {
84
+ __mmask16 mask = _mm512_cmp_ps_mask(a, _mm512_setzero_ps(), _CMP_NEQ_OQ);
85
+ return _mm512_maskz_mov_ps(mask, _mm512_set1_ps(1.f));
86
+ }
87
+
88
+ EIGEN_STRONG_INLINE Packet16f p_bool2float(const Packet16i& a)
89
+ {
90
+ return p_bool2float(_mm512_castsi512_ps(a));
91
+ }
92
+ }
93
+ }
94
+
95
+ inline __m512 lgamma_subt(__m512 z, __m512 a)
96
+ {
97
+ return lgamma512_subt(z, a);
98
+ }
99
+ #endif
59
100
  #ifdef EIGEN_VECTORIZE_SSE2
60
101
  #include <xmmintrin.h>
61
102
  #include "sse_gamma.h"
@@ -22,11 +22,11 @@ namespace tomoto
22
22
  ThreadPool(size_t threads = 0, size_t maxQueued = 0);
23
23
  template<class F, class... Args>
24
24
  auto enqueue(F&& f, Args&&... args)
25
- ->std::future<typename std::result_of<F(size_t, Args...)>::type>;
25
+ ->std::future<typename std::invoke_result_t<F, size_t, Args...>>;
26
26
 
27
27
  template<class F, class... Args>
28
28
  auto enqueueToAll(F&& f, Args&&... args)
29
- ->std::vector<std::future<typename std::result_of<F(size_t, Args...)>::type>>;
29
+ ->std::vector<std::future<typename std::invoke_result_t<F, size_t, Args...>>>;
30
30
 
31
31
  ~ThreadPool();
32
32
 
@@ -88,9 +88,9 @@ namespace tomoto
88
88
  // add new work item to the pool
89
89
  template<class F, class... Args>
90
90
  auto ThreadPool::enqueue(F&& f, Args&&... args)
91
- -> std::future<typename std::result_of<F(size_t, Args...)>::type>
91
+ -> std::future<typename std::invoke_result_t<F, size_t, Args...>>
92
92
  {
93
- using return_type = typename std::result_of<F(size_t, Args...)>::type;
93
+ using return_type = typename std::invoke_result_t<F, size_t, Args...>;
94
94
 
95
95
  auto task = std::make_shared< std::packaged_task<return_type(size_t)> >(
96
96
  std::bind(std::forward<F>(f), std::placeholders::_1, std::forward<Args>(args)...));
@@ -113,9 +113,9 @@ namespace tomoto
113
113
 
114
114
  template<class F, class... Args>
115
115
  auto ThreadPool::enqueueToAll(F&& f, Args&&... args)
116
- ->std::vector<std::future<typename std::result_of<F(size_t, Args...)>::type> >
116
+ ->std::vector<std::future<typename std::invoke_result_t<F, size_t, Args...>> >
117
117
  {
118
- using return_type = typename std::result_of<F(size_t, Args...)>::type;
118
+ using return_type = typename std::invoke_result_t<F, size_t, Args...>;
119
119
 
120
120
  std::vector<std::future<return_type> > ret;
121
121
  std::unique_lock<std::mutex> lock(queue_mutex);
@@ -296,9 +296,9 @@ namespace tomoto
296
296
  private:
297
297
  _UnaryFunc f;
298
298
  public:
299
- using reference = typename std::result_of<
300
- const _UnaryFunc(typename std::iterator_traits<_Iterator>::reference)
301
- >::type;
299
+ using reference = std::invoke_result_t<
300
+ const _UnaryFunc, typename std::iterator_traits<_Iterator>::reference
301
+ >;
302
302
  using value_type = reference;
303
303
 
304
304
  TransformIter(const _Iterator& _iter = {}, _UnaryFunc _f = {})
@@ -0,0 +1,46 @@
1
+ #pragma once
2
+ #include "avx512_mathfun.h"
3
+
4
+ // approximation : lgamma(z) ~= (z+2.5)ln(z+3) - z - 3 + 0.5 ln (2pi) + 1/12/(z + 3) - ln (z(z+1)(z+2))
5
+ inline __m512 lgamma512_ps(__m512 x)
6
+ {
7
+ __m512 x_3 = _mm512_add_ps(x, _mm512_set1_ps(3));
8
+ __m512 ret = _mm512_mul_ps(_mm512_add_ps(x_3, _mm512_set1_ps(-0.5f)), log512_ps(x_3));
9
+ ret = _mm512_sub_ps(ret, x_3);
10
+ ret = _mm512_add_ps(ret, _mm512_set1_ps(0.91893853f));
11
+ ret = _mm512_add_ps(ret, _mm512_div_ps(_mm512_set1_ps(1 / 12.f), x_3));
12
+ ret = _mm512_sub_ps(ret, log512_ps(_mm512_mul_ps(
13
+ _mm512_mul_ps(_mm512_sub_ps(x_3, _mm512_set1_ps(1)), _mm512_sub_ps(x_3, _mm512_set1_ps(2))), x)));
14
+ return ret;
15
+ }
16
+
17
+ // approximation : lgamma(z + a) - lgamma(z) = (z + a + 1.5) * log(z + a + 2) - (z + 1.5) * log(z + 2) - a + (1. / (z + a + 2) - 1. / (z + 2)) / 12. - log(((z + a) * (z + a + 1)) / (z * (z + 1)))
18
+ inline __m512 lgamma512_subt(__m512 z, __m512 a)
19
+ {
20
+ __m512 _1p5 = _mm512_set1_ps(1.5f);
21
+ __m512 _2 = _mm512_set1_ps(2.f);
22
+ __m512 za = _mm512_add_ps(z, a);
23
+ __m512 ret = _mm512_mul_ps(_mm512_add_ps(za, _1p5), log512_ps(_mm512_add_ps(za, _2)));
24
+ ret = _mm512_sub_ps(ret, _mm512_mul_ps(_mm512_add_ps(z, _1p5), log512_ps(_mm512_add_ps(z, _2))));
25
+ ret = _mm512_sub_ps(ret, a);
26
+ __m512 _1 = _mm512_set1_ps(1.f);
27
+ __m512 _1_12 = _mm512_set1_ps(1 / 12.f);
28
+ ret = _mm512_add_ps(ret, _mm512_sub_ps(_mm512_div_ps(_1_12, _mm512_add_ps(za, _2)), _mm512_div_ps(_1_12, _mm512_add_ps(z, _2))));
29
+ ret = _mm512_sub_ps(ret, log512_ps(_mm512_div_ps(_mm512_div_ps(_mm512_mul_ps(za, _mm512_add_ps(za, _1)), z), _mm512_add_ps(z, _1))));
30
+ return ret;
31
+ }
32
+
33
+
34
+ // approximation : digamma(z) ~= ln(z+4) - 1/2/(z+4) - 1/12/(z+4)^2 - 1/z - 1/(z+1) - 1/(z+2) - 1/(z+3)
35
+ inline __m512 digamma512_ps(__m512 x)
36
+ {
37
+ __m512 x_4 = _mm512_add_ps(x, _mm512_set1_ps(4));
38
+ __m512 ret = log512_ps(x_4);
39
+ ret = _mm512_sub_ps(ret, _mm512_div_ps(_mm512_set1_ps(1 / 2.f), x_4));
40
+ ret = _mm512_sub_ps(ret, _mm512_div_ps(_mm512_div_ps(_mm512_set1_ps(1 / 12.f), x_4), x_4));
41
+ ret = _mm512_sub_ps(ret, _mm512_rcp14_ps(_mm512_sub_ps(x_4, _mm512_set1_ps(1))));
42
+ ret = _mm512_sub_ps(ret, _mm512_rcp14_ps(_mm512_sub_ps(x_4, _mm512_set1_ps(2))));
43
+ ret = _mm512_sub_ps(ret, _mm512_rcp14_ps(_mm512_sub_ps(x_4, _mm512_set1_ps(3))));
44
+ ret = _mm512_sub_ps(ret, _mm512_rcp14_ps(_mm512_sub_ps(x_4, _mm512_set1_ps(4))));
45
+ return ret;
46
+ }
@@ -0,0 +1,99 @@
1
+ /*
2
+ AVX-512 implementation of log function
3
+
4
+ Based on "avx_mathfun.h" by Giovanni Garberoglio
5
+ and "sse_mathfun.h" by Julien Pommier
6
+ */
7
+
8
+ #pragma once
9
+ #include <immintrin.h>
10
+
11
+ #ifdef _MSC_VER
12
+ #define ALIGN64_BEG __declspec(align(64))
13
+ #define ALIGN64_END
14
+ #else
15
+ #define ALIGN64_BEG
16
+ #define ALIGN64_END __attribute__((aligned(64)))
17
+ #endif
18
+
19
+ typedef __m512 v16sf;
20
+ typedef __m512i v16si;
21
+
22
+ #define _PS512_CONST(Name, Val) \
23
+ static const ALIGN64_BEG float _ps512_##Name[16] ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }
24
+ #define _PI32_CONST512(Name, Val) \
25
+ static const ALIGN64_BEG int _pi32_512_##Name[16] ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }
26
+ #define _PS512_CONST_TYPE(Name, Type, Val) \
27
+ static const ALIGN64_BEG Type _ps512_##Name[16] ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }
28
+
29
+ _PS512_CONST(1, 1.0f);
30
+ _PS512_CONST(0p5, 0.5f);
31
+ _PS512_CONST_TYPE(min_norm_pos, unsigned int, 0x00800000u);
32
+ _PS512_CONST_TYPE(inv_mant_mask, unsigned int, ~0x7f800000u);
33
+
34
+ _PI32_CONST512(0x7f, 0x7f);
35
+
36
+ _PS512_CONST(cephes_SQRTHF, 0.707106781186547524f);
37
+ _PS512_CONST(cephes_log_p0, 7.0376836292E-2f);
38
+ _PS512_CONST(cephes_log_p1, -1.1514610310E-1f);
39
+ _PS512_CONST(cephes_log_p2, 1.1676998740E-1f);
40
+ _PS512_CONST(cephes_log_p3, -1.2420140846E-1f);
41
+ _PS512_CONST(cephes_log_p4, +1.4249322787E-1f);
42
+ _PS512_CONST(cephes_log_p5, -1.6668057665E-1f);
43
+ _PS512_CONST(cephes_log_p6, +2.0000714765E-1f);
44
+ _PS512_CONST(cephes_log_p7, -2.4999993993E-1f);
45
+ _PS512_CONST(cephes_log_p8, +3.3333331174E-1f);
46
+ _PS512_CONST(cephes_log_q1, -2.12194440e-4f);
47
+ _PS512_CONST(cephes_log_q2, 0.693359375f);
48
+
49
+ /* natural logarithm computed for 16 simultaneous float */
50
+ inline v16sf log512_ps(v16sf x) {
51
+ v16si imm0;
52
+ v16sf one = *(v16sf*)_ps512_1;
53
+
54
+ __mmask16 invalid_mask = _mm512_cmp_ps_mask(x, _mm512_setzero_ps(), _CMP_LE_OS);
55
+
56
+ x = _mm512_max_ps(x, *(v16sf*)_ps512_min_norm_pos);
57
+
58
+ imm0 = _mm512_srli_epi32(_mm512_castps_si512(x), 23);
59
+
60
+ x = _mm512_and_ps(x, *(v16sf*)_ps512_inv_mant_mask);
61
+ x = _mm512_or_ps(x, *(v16sf*)_ps512_0p5);
62
+
63
+ imm0 = _mm512_sub_epi32(imm0, *(v16si*)_pi32_512_0x7f);
64
+ v16sf e = _mm512_cvtepi32_ps(imm0);
65
+
66
+ e = _mm512_add_ps(e, one);
67
+
68
+ __mmask16 mask = _mm512_cmp_ps_mask(x, *(v16sf*)_ps512_cephes_SQRTHF, _CMP_LT_OS);
69
+ v16sf tmp = _mm512_maskz_mov_ps(mask, x);
70
+ x = _mm512_sub_ps(x, one);
71
+ e = _mm512_mask_sub_ps(e, mask, e, one);
72
+ x = _mm512_add_ps(x, tmp);
73
+
74
+ v16sf z = _mm512_mul_ps(x, x);
75
+
76
+ v16sf y = *(v16sf*)_ps512_cephes_log_p0;
77
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p1);
78
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p2);
79
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p3);
80
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p4);
81
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p5);
82
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p6);
83
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p7);
84
+ y = _mm512_fmadd_ps(y, x, *(v16sf*)_ps512_cephes_log_p8);
85
+ y = _mm512_mul_ps(y, x);
86
+
87
+ y = _mm512_mul_ps(y, z);
88
+
89
+ y = _mm512_fmadd_ps(e, *(v16sf*)_ps512_cephes_log_q1, y);
90
+
91
+ tmp = _mm512_mul_ps(z, *(v16sf*)_ps512_0p5);
92
+ y = _mm512_sub_ps(y, tmp);
93
+
94
+ x = _mm512_fmadd_ps(e, *(v16sf*)_ps512_cephes_log_q2, _mm512_add_ps(x, y));
95
+
96
+ // negative arg will be NAN
97
+ x = _mm512_mask_blend_ps(invalid_mask, x, _mm512_set1_ps(__builtin_nanf("")));
98
+ return x;
99
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomoto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -64,6 +64,7 @@ files:
64
64
  - lib/tomoto/slda.rb
65
65
  - lib/tomoto/version.rb
66
66
  - vendor/EigenRand/EigenRand/Core.h
67
+ - vendor/EigenRand/EigenRand/CwiseHeteroBinaryOp.h
67
68
  - vendor/EigenRand/EigenRand/Dists/Basic.h
68
69
  - vendor/EigenRand/EigenRand/Dists/Discrete.h
69
70
  - vendor/EigenRand/EigenRand/Dists/GammaPoisson.h
@@ -79,6 +80,9 @@ files:
79
80
  - vendor/EigenRand/EigenRand/arch/AVX/MorePacketMath.h
80
81
  - vendor/EigenRand/EigenRand/arch/AVX/PacketFilter.h
81
82
  - vendor/EigenRand/EigenRand/arch/AVX/RandUtils.h
83
+ - vendor/EigenRand/EigenRand/arch/AVX512/MorePacketMath.h
84
+ - vendor/EigenRand/EigenRand/arch/AVX512/PacketFilter.h
85
+ - vendor/EigenRand/EigenRand/arch/AVX512/RandUtils.h
82
86
  - vendor/EigenRand/EigenRand/arch/NEON/MorePacketMath.h
83
87
  - vendor/EigenRand/EigenRand/arch/NEON/PacketFilter.h
84
88
  - vendor/EigenRand/EigenRand/arch/NEON/RandUtils.h
@@ -447,6 +451,8 @@ files:
447
451
  - vendor/tomotopy/LICENSE
448
452
  - vendor/tomotopy/README.kr.rst
449
453
  - vendor/tomotopy/README.rst
454
+ - vendor/tomotopy/README_pypi.rst
455
+ - vendor/tomotopy/licenses_bundled/EigenRand
450
456
  - vendor/tomotopy/src/Labeling/FoRelevance.cpp
451
457
  - vendor/tomotopy/src/Labeling/FoRelevance.h
452
458
  - vendor/tomotopy/src/Labeling/Labeler.h
@@ -516,6 +522,8 @@ files:
516
522
  - vendor/tomotopy/src/Utils/Trie.hpp
517
523
  - vendor/tomotopy/src/Utils/TruncMultiNormal.hpp
518
524
  - vendor/tomotopy/src/Utils/Utils.hpp
525
+ - vendor/tomotopy/src/Utils/avx512_gamma.h
526
+ - vendor/tomotopy/src/Utils/avx512_mathfun.h
519
527
  - vendor/tomotopy/src/Utils/avx_gamma.h
520
528
  - vendor/tomotopy/src/Utils/avx_mathfun.h
521
529
  - vendor/tomotopy/src/Utils/exception.h
@@ -530,13 +538,6 @@ files:
530
538
  - vendor/tomotopy/src/Utils/sse_mathfun.h
531
539
  - vendor/tomotopy/src/Utils/text.hpp
532
540
  - vendor/tomotopy/src/Utils/tvector.hpp
533
- - vendor/variant/LICENSE
534
- - vendor/variant/LICENSE_1_0.txt
535
- - vendor/variant/README.md
536
- - vendor/variant/include/mapbox/optional.hpp
537
- - vendor/variant/include/mapbox/recursive_wrapper.hpp
538
- - vendor/variant/include/mapbox/variant.hpp
539
- - vendor/variant/include/mapbox/variant_io.hpp
540
541
  homepage: https://github.com/ankane/tomoto-ruby
541
542
  licenses:
542
543
  - MIT
@@ -555,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
556
  - !ruby/object:Gem::Version
556
557
  version: '0'
557
558
  requirements: []
558
- rubygems_version: 3.6.9
559
+ rubygems_version: 4.0.3
559
560
  specification_version: 4
560
561
  summary: High performance topic modeling for Ruby
561
562
  test_files: []
@@ -1,25 +0,0 @@
1
- Copyright (c) MapBox
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification,
5
- are permitted provided that the following conditions are met:
6
-
7
- - Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
- - Redistributions in binary form must reproduce the above copyright notice, this
10
- list of conditions and the following disclaimer in the documentation and/or
11
- other materials provided with the distribution.
12
- - Neither the name "MapBox" nor the names of its contributors may be
13
- used to endorse or promote products derived from this software without
14
- specific prior written permission.
15
-
16
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
20
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,23 +0,0 @@
1
- Boost Software License - Version 1.0 - August 17th, 2003
2
-
3
- Permission is hereby granted, free of charge, to any person or organization
4
- obtaining a copy of the software and accompanying documentation covered by
5
- this license (the "Software") to use, reproduce, display, distribute,
6
- execute, and transmit the Software, and to prepare derivative works of the
7
- Software, and to permit third-parties to whom the Software is furnished to
8
- do so, all subject to the following:
9
-
10
- The copyright notices in the Software and this entire statement, including
11
- the above license grant, this restriction and the following disclaimer,
12
- must be included in all copies of the Software, in whole or in part, and
13
- all derivative works of the Software, unless such copies or derivative
14
- works are solely in the form of machine-executable object code generated by
15
- a source language processor.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
- DEALINGS IN THE SOFTWARE.