mfilter 0.2.1.1 → 0.2.2.1
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/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/ext/mfilter/extconf.rb +38 -7
- data/ext/mfilter/main.cc +7 -7
- data/lib/mfilter/version.rb +1 -1
- data/lib/mfilter.rb +9 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92f3f4d6bb904ff5028bd69a49711b9fbd2ecc04e16778ed92e6cfadb38b2023
|
4
|
+
data.tar.gz: c18409a8f3dc57a11797182746b3e03004ac28096f79c2057b317f5d76fb5471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a0da98b651a86419f7d427ad51abcdd74380c32e6de3b3e154a3dab58e99428e5b146b8bc3847a46101650c96cbe44600d30d3721df362dcb9b6376ec1397c
|
7
|
+
data.tar.gz: d7347745a935d5e8e333305b6ee7a52849167a98a6f5d72c8d7a653131d388839e117963e2c45218bbfc24dce43d4faacb7547ad00d02bd6fdfbfc410f6e112d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/ext/mfilter/extconf.rb
CHANGED
@@ -1,13 +1,44 @@
|
|
1
1
|
require "mkmf"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
# homebrew で Octave がインストールされている場合
|
4
|
+
oct_inc_dir = Dir.glob("#{ENV["HOME"]}/.linuxbrew/include/octave-*")
|
5
|
+
unless oct_inc_dir.empty?
|
6
|
+
oct_inc_dir = oct_inc_dir[0]
|
7
|
+
if File.exist? oct_inc_dir
|
8
|
+
oct_inc_dir =~ /-(.*)$/
|
9
|
+
oct_ver = $1
|
10
|
+
else
|
11
|
+
raise
|
12
|
+
end
|
13
|
+
oct_inc_dir += "/octave"
|
14
|
+
oct_lib_dir = "#{ENV["HOME"]}/.linuxbrew/lib/octave/#{oct_ver}"
|
15
|
+
oct_lib_dir = File.exist?(oct_lib_dir) ? oct_lib_dir : nil
|
16
|
+
else
|
17
|
+
oct_inc_dir = Dir.glob("/usr/include/octave-*")
|
18
|
+
unless oct_inc_dir.empty?
|
19
|
+
oct_inc_dir = oct_inc_dir[0]
|
20
|
+
if File.exist? oct_inc_dir
|
21
|
+
oct_inc_dir =~ /-(.*)$/
|
22
|
+
oct_ver = $1
|
23
|
+
else
|
24
|
+
raise
|
25
|
+
end
|
26
|
+
oct_inc_dir += "/octave"
|
27
|
+
oct_lib_dir = "/usr/lib/x86_64-linux-gnu/octave/#{oct_ver}"
|
28
|
+
oct_lib_dir = File.exist?(oct_lib_dir) ? oct_lib_dir : nil
|
29
|
+
else
|
30
|
+
raise "Octave がインストールされていません"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
$LDFLAGS += " -L#{oct_lib_dir}"
|
34
|
+
$INCFLAGS += " -I#{oct_inc_dir}"
|
35
|
+
$libs += " -loctinterp"
|
36
|
+
|
37
|
+
|
8
38
|
|
9
39
|
narray_dir = Gem.find_files("numo").map{|e| e.include?("narray") ? e : false}.select{|e| e}.to_a[0]
|
10
|
-
|
11
|
-
|
40
|
+
$LDFLAGS += " -L#{narray_dir}"
|
41
|
+
$INCFLAGS += " -I#{narray_dir}"
|
42
|
+
$libs += " #{narray_dir}/narray.so"
|
12
43
|
|
13
44
|
create_makefile "mfilter"
|
data/ext/mfilter/main.cc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#include <
|
1
|
+
#include <oct.h>
|
2
2
|
#include <iostream>
|
3
3
|
#include <math.h>
|
4
4
|
#include <vector>
|
@@ -44,10 +44,11 @@ VALUE rb_na_filter(VALUE self, VALUE b, VALUE a, VALUE x, VALUE si){
|
|
44
44
|
|
45
45
|
|
46
46
|
VALUE rb_m_filter(VALUE self, VALUE b, VALUE a, VALUE x, VALUE si){
|
47
|
+
long len[3] = {RARRAY_LEN(b), RARRAY_LEN(a), RARRAY_LEN(x)};
|
47
48
|
MArray<double>
|
48
|
-
mb(dim_vector(
|
49
|
-
ma(dim_vector(
|
50
|
-
mx(dim_vector(
|
49
|
+
mb(dim_vector(len[0], 1)),
|
50
|
+
ma(dim_vector(len[1], 1)),
|
51
|
+
mx(dim_vector(len[2], 1)),
|
51
52
|
my;
|
52
53
|
double* p[3] = {(double*)mb.data(), (double*)ma.data(), (double*)mx.data()};
|
53
54
|
const VALUE* pr[3] = {
|
@@ -55,12 +56,11 @@ VALUE rb_m_filter(VALUE self, VALUE b, VALUE a, VALUE x, VALUE si){
|
|
55
56
|
RARRAY_CONST_PTR_TRANSIENT(a),
|
56
57
|
RARRAY_CONST_PTR_TRANSIENT(x)
|
57
58
|
};
|
58
|
-
long len[3] = {RARRAY_LEN(b), RARRAY_LEN(a), RARRAY_LEN(x)};
|
59
59
|
VALUE y;
|
60
60
|
for(int n = 0; n < 3; n++)
|
61
61
|
for(long i = 0; i < len[n]; i++)
|
62
62
|
p[n][i] = NUM2DBL(pr[n][i]);
|
63
|
-
|
63
|
+
|
64
64
|
if(si == Qnil)
|
65
65
|
my = filter(mb, ma, mx);
|
66
66
|
else if(rb_obj_class(si) == rb_cArray){
|
@@ -71,7 +71,7 @@ VALUE rb_m_filter(VALUE self, VALUE b, VALUE a, VALUE x, VALUE si){
|
|
71
71
|
}
|
72
72
|
else
|
73
73
|
rb_raise(rb_eTypeError, "si should belong to Array class");
|
74
|
-
|
74
|
+
|
75
75
|
y = rb_ary_new();
|
76
76
|
for(long i = 0; i < RARRAY_LEN(x); i++)
|
77
77
|
rb_ary_store(y, i, DBL2NUM(my(i, 0)));
|
data/lib/mfilter/version.rb
CHANGED
data/lib/mfilter.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
require_relative "mfilter/version"
|
4
4
|
|
5
5
|
require "numo/narray"
|
6
|
+
|
7
|
+
# ENV["LD_PRELOAD"] = "/mnt/export1/st3/b033vbv/.linuxbrew/lib/libz.so"
|
8
|
+
ENV.update({"LD_PRELOAD" => "/mnt/export1/st3/b033vbv/.linuxbrew/lib/libz.so"})
|
9
|
+
|
6
10
|
require "mfilter.so"
|
7
11
|
|
8
12
|
module MFilter
|
@@ -15,6 +19,11 @@ module MFilter
|
|
15
19
|
raise TypeError, "si should be nil or belong to Array class" unless si.is_a? Array or si.nil? or si.is_a? Numo::DFloat
|
16
20
|
b = [b.to_f] if b.is_a? Numeric
|
17
21
|
a = [a.to_f] if a.is_a? Numeric
|
22
|
+
|
23
|
+
if b.is_a?(Array) and a.is_a?(Array) and x.is_a?(Array)
|
24
|
+
return _filter(b, a, x, si)
|
25
|
+
end
|
26
|
+
|
18
27
|
b, a, x = [Numo::DFloat.cast(b), Numo::DFloat.cast(a), Numo::DFloat.cast(x)]
|
19
28
|
si = Numo::DFloat.cast(si) if si
|
20
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mfilter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murata Mitsuharu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08
|
11
|
+
date: 2021-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.2.0
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- hikari.photon+dev@gmail.com
|
58
58
|
executables: []
|
@@ -76,11 +76,11 @@ files:
|
|
76
76
|
- lib/mfilter/version.rb
|
77
77
|
- mfilter.gemspec
|
78
78
|
- mkmf.log
|
79
|
-
homepage:
|
79
|
+
homepage:
|
80
80
|
licenses:
|
81
81
|
- GPL-3
|
82
82
|
metadata: {}
|
83
|
-
post_install_message:
|
83
|
+
post_install_message:
|
84
84
|
rdoc_options: []
|
85
85
|
require_paths:
|
86
86
|
- lib
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubygems_version: 3.2.22
|
100
|
-
signing_key:
|
100
|
+
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Function module similar to `filter` in MatLab or Octave.
|
103
103
|
test_files: []
|