stl-rb 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +3 -3
- data/ext/stl/ext.cpp +32 -27
- data/ext/stl/extconf.rb +1 -1
- data/ext/stl/stl.hpp +634 -242
- data/lib/stl/version.rb +1 -1
- data/lib/stl.rb +13 -13
- metadata +6 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f14115c449f63656bd2e3ca2dc99d3ff7333f666624b6de9dbf85782da52c217
|
|
4
|
+
data.tar.gz: 020f4e169a0a594b6e4c650d2c5386fdca1e08887aa78ae2056e1cf923705aa7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad513afa05023950ce775cd7d6e197a214b9fdf875720325304dfd2091131e90f5673b268b46af170f4162573088b4aa4154f6fed28afa35f8e88ce6b5f5221b
|
|
7
|
+
data.tar.gz: 1e6f96c7c3a456db12685c7f64e3c31e30b7bcc35eef1dba7f7bcba0d319bd08e00c1fc43edc34bdcc988e0f27ea8e4a64f368cb3ca81e4ddac31ed5466a0799
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -18,9 +18,9 @@ Decompose a time series
|
|
|
18
18
|
|
|
19
19
|
```ruby
|
|
20
20
|
series = {
|
|
21
|
-
Date.parse("
|
|
22
|
-
Date.parse("
|
|
23
|
-
Date.parse("
|
|
21
|
+
Date.parse("2025-01-01") => 100,
|
|
22
|
+
Date.parse("2025-01-02") => 150,
|
|
23
|
+
Date.parse("2025-01-03") => 136,
|
|
24
24
|
# ...
|
|
25
25
|
}
|
|
26
26
|
|
data/ext/stl/ext.cpp
CHANGED
|
@@ -1,45 +1,50 @@
|
|
|
1
|
+
#include <cstddef>
|
|
2
|
+
#include <vector>
|
|
3
|
+
|
|
1
4
|
#include <rice/rice.hpp>
|
|
2
|
-
#include <rice/stl.hpp>
|
|
3
5
|
|
|
4
6
|
#include "stl.hpp"
|
|
5
7
|
|
|
6
|
-
Rice::Array to_a(std::vector<float>& x) {
|
|
7
|
-
|
|
8
|
-
for (auto v : x) {
|
|
9
|
-
a.push(v);
|
|
8
|
+
Rice::Array to_a(const std::vector<float>& x) {
|
|
9
|
+
Rice::Array a;
|
|
10
|
+
for (const auto v : x) {
|
|
11
|
+
a.push(v, false);
|
|
10
12
|
}
|
|
11
13
|
return a;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
extern "C"
|
|
15
17
|
void Init_ext() {
|
|
16
|
-
|
|
18
|
+
Rice::Module rb_mStl = Rice::define_module("Stl");
|
|
17
19
|
|
|
18
20
|
Rice::define_class_under<stl::StlParams>(rb_mStl, "StlParams")
|
|
19
21
|
.define_constructor(Rice::Constructor<stl::StlParams>())
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.
|
|
28
|
-
.
|
|
29
|
-
.
|
|
30
|
-
.
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
.define_attr("seasonal_length", &stl::StlParams::seasonal_length)
|
|
23
|
+
.define_attr("trend_length", &stl::StlParams::trend_length)
|
|
24
|
+
.define_attr("low_pass_length", &stl::StlParams::low_pass_length)
|
|
25
|
+
.define_attr("seasonal_degree", &stl::StlParams::seasonal_degree)
|
|
26
|
+
.define_attr("trend_degree", &stl::StlParams::trend_degree)
|
|
27
|
+
.define_attr("low_pass_degree", &stl::StlParams::low_pass_degree)
|
|
28
|
+
.define_attr("seasonal_jump", &stl::StlParams::seasonal_jump)
|
|
29
|
+
.define_attr("trend_jump", &stl::StlParams::trend_jump)
|
|
30
|
+
.define_attr("low_pass_jump", &stl::StlParams::low_pass_jump)
|
|
31
|
+
.define_attr("inner_loops", &stl::StlParams::inner_loops)
|
|
32
|
+
.define_attr("outer_loops", &stl::StlParams::outer_loops)
|
|
33
|
+
.define_attr("robust", &stl::StlParams::robust);
|
|
34
|
+
|
|
35
|
+
rb_mStl
|
|
36
|
+
.define_singleton_function(
|
|
37
|
+
"_decompose",
|
|
38
|
+
[](Rice::Array rb_series, size_t period, const stl::StlParams& params, bool weights) {
|
|
39
|
+
std::vector<float> series = rb_series.to_vector<float>();
|
|
40
|
+
stl::Stl fit{series, period, params};
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
ret[Rice::Symbol("seasonal")] = to_a(
|
|
39
|
-
ret[Rice::Symbol("trend")] = to_a(
|
|
40
|
-
ret[Rice::Symbol("remainder")] = to_a(
|
|
42
|
+
Rice::Hash ret;
|
|
43
|
+
ret[Rice::Symbol("seasonal")] = to_a(fit.seasonal());
|
|
44
|
+
ret[Rice::Symbol("trend")] = to_a(fit.trend());
|
|
45
|
+
ret[Rice::Symbol("remainder")] = to_a(fit.remainder());
|
|
41
46
|
if (weights) {
|
|
42
|
-
ret[Rice::Symbol("weights")] = to_a(
|
|
47
|
+
ret[Rice::Symbol("weights")] = to_a(fit.weights());
|
|
43
48
|
}
|
|
44
49
|
return ret;
|
|
45
50
|
});
|
data/ext/stl/extconf.rb
CHANGED