tomoto 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/tomoto/ct.cpp +11 -11
- data/ext/tomoto/dmr.cpp +14 -13
- data/ext/tomoto/dt.cpp +14 -14
- data/ext/tomoto/ext.cpp +7 -7
- data/ext/tomoto/extconf.rb +1 -3
- data/ext/tomoto/gdmr.cpp +7 -7
- data/ext/tomoto/hdp.cpp +9 -9
- data/ext/tomoto/hlda.cpp +13 -13
- data/ext/tomoto/hpa.cpp +5 -5
- data/ext/tomoto/lda.cpp +42 -39
- data/ext/tomoto/llda.cpp +6 -6
- data/ext/tomoto/mglda.cpp +15 -15
- data/ext/tomoto/pa.cpp +6 -6
- data/ext/tomoto/plda.cpp +6 -6
- data/ext/tomoto/slda.cpp +8 -8
- data/ext/tomoto/utils.h +16 -70
- data/lib/tomoto/version.rb +1 -1
- data/vendor/tomotopy/README.kr.rst +57 -0
- data/vendor/tomotopy/README.rst +55 -0
- data/vendor/tomotopy/src/Labeling/Phraser.hpp +3 -3
- data/vendor/tomotopy/src/TopicModel/CTModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/DTModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +4 -4
- data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +2 -2
- data/vendor/tomotopy/src/TopicModel/LDA.h +3 -3
- data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +3 -3
- data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +34 -14
- data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +2 -2
- data/vendor/tomotopy/src/TopicModel/PAModel.hpp +1 -1
- data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/PTModel.hpp +5 -2
- data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +4 -1
- data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +48 -21
- data/vendor/tomotopy/src/Utils/AliasMethod.hpp +5 -4
- data/vendor/tomotopy/src/Utils/Dictionary.h +2 -2
- data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +1 -1
- data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +1 -1
- data/vendor/tomotopy/src/Utils/math.h +2 -2
- data/vendor/tomotopy/src/Utils/serializer.hpp +30 -5
- metadata +6 -6
@@ -35,11 +35,12 @@ namespace tomoto
|
|
35
35
|
bitsize = o.bitsize;
|
36
36
|
if (msize)
|
37
37
|
{
|
38
|
-
|
39
|
-
|
38
|
+
size_t n = (size_t)1 << bitsize;
|
39
|
+
arr = std::make_unique<_Precision[]>(n);
|
40
|
+
alias = std::make_unique<size_t[]>(n);
|
40
41
|
|
41
|
-
std::copy(o.arr.get(), o.arr.get() +
|
42
|
-
std::copy(o.alias.get(), o.alias.get() +
|
42
|
+
std::copy(o.arr.get(), o.arr.get() + n, arr.get());
|
43
|
+
std::copy(o.alias.get(), o.alias.get() + n, alias.get());
|
43
44
|
}
|
44
45
|
return *this;
|
45
46
|
}
|
@@ -32,7 +32,7 @@ namespace tomoto
|
|
32
32
|
auto it = dict.find(word);
|
33
33
|
if (it == dict.end())
|
34
34
|
{
|
35
|
-
dict.emplace(
|
35
|
+
dict.emplace(word, (Vid)dict.size());
|
36
36
|
id2word.emplace_back(word);
|
37
37
|
return (Vid)(dict.size() - 1);
|
38
38
|
}
|
@@ -64,7 +64,7 @@ namespace tomoto
|
|
64
64
|
serializer::readMany(reader, serializer::to_key("Dict"), id2word);
|
65
65
|
for (size_t i = 0; i < id2word.size(); ++i)
|
66
66
|
{
|
67
|
-
dict.emplace(id2word[i], i);
|
67
|
+
dict.emplace(id2word[i], (Vid)i);
|
68
68
|
}
|
69
69
|
}
|
70
70
|
|
@@ -10,7 +10,7 @@ namespace tomoto
|
|
10
10
|
template<typename _Ty = float>
|
11
11
|
struct MultiNormalDistribution
|
12
12
|
{
|
13
|
-
static constexpr _Ty log2pi = 1.83787706641;
|
13
|
+
static constexpr _Ty log2pi = (_Ty)1.83787706641;
|
14
14
|
Eigen::Matrix<_Ty, -1, 1> mean;
|
15
15
|
Eigen::Matrix<_Ty, -1, -1> cov, l;
|
16
16
|
_Ty logDet = 0;
|
@@ -141,9 +141,9 @@ namespace tomoto
|
|
141
141
|
float forSmall(float x)
|
142
142
|
{
|
143
143
|
if (x == 0) return -INFINITY;
|
144
|
-
return
|
144
|
+
return logf(x + 2) - 0.5f / (x + 2) - 1 / 12.f / powf(x + 2, 2) - 1 / (x + 1) - 1 / x;
|
145
145
|
}
|
146
|
-
float forLarge(float x) { return
|
146
|
+
float forLarge(float x) { return logf(x) - 0.5f / x - 1 / 12.f / powf(x, 2); }
|
147
147
|
float forNonFinite(float x) { if (std::isnan(x) || x < 0) return NAN; return INFINITY;}
|
148
148
|
};
|
149
149
|
|
@@ -89,7 +89,7 @@ namespace tomoto
|
|
89
89
|
template<> struct gen_seq<1> : seq<0> {};
|
90
90
|
|
91
91
|
template <size_t _n, size_t ... _is>
|
92
|
-
std::array<char,
|
92
|
+
constexpr std::array<char, sizeof... (_is)> to_array(const char(&a)[_n], seq<_is...>)
|
93
93
|
{
|
94
94
|
return { {a[_is]...} };
|
95
95
|
}
|
@@ -101,7 +101,13 @@ namespace tomoto
|
|
101
101
|
}
|
102
102
|
|
103
103
|
template <size_t _n, size_t ... _is>
|
104
|
-
std::array<char,
|
104
|
+
constexpr std::array<char, sizeof... (_is) + 1> to_arrayz(const char(&a)[_n], seq<_is...>)
|
105
|
+
{
|
106
|
+
return { {a[_is]..., 0} };
|
107
|
+
}
|
108
|
+
|
109
|
+
template <size_t _n, size_t ... _is>
|
110
|
+
constexpr std::array<char, sizeof... (_is) + 1> to_arrayz(const std::array<char, _n>& a, seq<_is...>)
|
105
111
|
{
|
106
112
|
return { {a[_is]..., 0} };
|
107
113
|
}
|
@@ -132,17 +138,24 @@ namespace tomoto
|
|
132
138
|
return std::string{ m.begin(), m.end() };
|
133
139
|
}
|
134
140
|
|
135
|
-
Key(const std::array<char, _len>& _m) : m(_m)
|
141
|
+
constexpr Key(const std::array<char, _len>& _m) : m(_m)
|
136
142
|
{
|
137
143
|
}
|
138
144
|
|
139
|
-
Key(std::array<char, _len>&& _m) : m(_m)
|
145
|
+
constexpr Key(std::array<char, _len>&& _m) : m(_m)
|
140
146
|
{
|
141
147
|
}
|
142
148
|
|
143
|
-
Key(const char(&a)[_len + 1]) : Key{ detail::to_array(a) }
|
149
|
+
constexpr Key(const char(&a)[_len + 1]) : Key{ detail::to_array(a) }
|
144
150
|
{
|
145
151
|
}
|
152
|
+
|
153
|
+
constexpr char operator[](size_t n) const
|
154
|
+
{
|
155
|
+
return n < _len ? m[n] : throw std::out_of_range("");
|
156
|
+
}
|
157
|
+
|
158
|
+
constexpr size_t size() const { return _len; }
|
146
159
|
};
|
147
160
|
|
148
161
|
template<typename _Ty>
|
@@ -161,12 +174,24 @@ namespace tomoto
|
|
161
174
|
return Key<_n - 1>{detail::to_array(a)};
|
162
175
|
}
|
163
176
|
|
177
|
+
template<size_t _n>
|
178
|
+
constexpr Key<_n> to_key(const Key<_n>& key)
|
179
|
+
{
|
180
|
+
return key;
|
181
|
+
}
|
182
|
+
|
164
183
|
template<size_t _n>
|
165
184
|
constexpr Key<_n> to_keyz(const char(&a)[_n])
|
166
185
|
{
|
167
186
|
return Key<_n>{detail::to_arrayz(a)};
|
168
187
|
}
|
169
188
|
|
189
|
+
template<size_t _n>
|
190
|
+
constexpr Key<_n + 1> to_keyz(const Key<_n>& key)
|
191
|
+
{
|
192
|
+
return Key<_n + 1>{detail::to_arrayz(key.m, detail::GenSeq<_n>{})};
|
193
|
+
}
|
194
|
+
|
170
195
|
template<typename _Ty, typename = void>
|
171
196
|
struct Serializer;
|
172
197
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomoto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rice
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4'
|
27
27
|
description:
|
28
28
|
email: andrew@ankane.org
|
29
29
|
executables: []
|