mfilter 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +22 -0
- data/README.md +31 -0
- data/Rakefile +9 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ext/.gitignore +1 -0
- data/ext/mfilter/extconf.rb +7 -0
- data/ext/mfilter/filter.hpp +7 -0
- data/ext/mfilter/main.cc +32 -0
- data/lib/mfilter/version.rb +5 -0
- data/lib/mfilter.rb +10 -0
- data/mfilter.gemspec +23 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1e7491f56a38d509d83bdf57aa7dd2a04f63db5c51c29563d1a9e19a2820b16
|
4
|
+
data.tar.gz: a3cce8b1e0eb5513cdf22f59d09ab115218fb2254eb9a46a0532673b137e3cce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2952d39fe2c612faca418d07bd01bb4042787c8898ce7933d3ca77eb5ccfd4ee18a25433788095e623bc0ca7c3cb44fcb4e3b5a8e520aa6f5a9ae7f02d4f8102
|
7
|
+
data.tar.gz: 8baf7ca30f4223ca67e5a1c8b73fa0b74058e0dfdf4fa1e6feeef757495519078009281214628bfbc108ff4eae67a143150ad10d5f357d812a45d9d07ff49968
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mfilter (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (13.0.6)
|
10
|
+
rake-compiler (1.1.1)
|
11
|
+
rake
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
x86_64-linux
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
mfilter!
|
18
|
+
rake (~> 13.0)
|
19
|
+
rake-compiler (~> 1.1.1)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
2.2.1
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Mfilter
|
2
|
+
MatLab (Octave) ライクの `filter` 関数の Ruby 実装。
|
3
|
+
|
4
|
+
## インストール方法
|
5
|
+
|
6
|
+
### 依存
|
7
|
+
- liboctave.so
|
8
|
+
- liboctinterp.so
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "mfilter", github: "himeyama/mfilter.git", branch: :main
|
12
|
+
```
|
13
|
+
|
14
|
+
Gem のインストールを実行:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
または、
|
19
|
+
|
20
|
+
$ gem install specific_install
|
21
|
+
$ gem specific_install -l "himeyama/mfilter.git"
|
22
|
+
|
23
|
+
## 使用法
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "mfilter"
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/himeyama/mfilter.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "mfilter"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/ext/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.so
|
data/ext/mfilter/main.cc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <octave-5.2.0/octave/oct.h>
|
2
|
+
#include <iostream>
|
3
|
+
#include <math.h>
|
4
|
+
#include <vector>
|
5
|
+
#include "filter.hpp"
|
6
|
+
#include <ruby.h>
|
7
|
+
|
8
|
+
|
9
|
+
VALUE rb_m_filter(VALUE self, VALUE b, VALUE a, VALUE x){
|
10
|
+
MArray<double>
|
11
|
+
mb(dim_vector(RARRAY_LEN(b), 1)),
|
12
|
+
ma(dim_vector(RARRAY_LEN(a), 1)),
|
13
|
+
mx(dim_vector(RARRAY_LEN(x), 1));
|
14
|
+
for(long i = 0; i < RARRAY_LEN(b); i++)
|
15
|
+
mb(i, 0) = NUM2DBL(rb_ary_entry(b, i));
|
16
|
+
for(long i = 0; i < RARRAY_LEN(a); i++)
|
17
|
+
ma(i, 0) = NUM2DBL(rb_ary_entry(a, i));
|
18
|
+
for(long i = 0; i < RARRAY_LEN(x); i++)
|
19
|
+
mx(i, 0) = NUM2DBL(rb_ary_entry(x, i));
|
20
|
+
MArray<double> my = filter(mb, ma, mx);
|
21
|
+
VALUE y = rb_ary_new();
|
22
|
+
for(long i = 0; i < RARRAY_LEN(x); i++)
|
23
|
+
rb_ary_store(y, i, DBL2NUM(my(i, 0)));
|
24
|
+
return y;
|
25
|
+
}
|
26
|
+
|
27
|
+
extern "C"{
|
28
|
+
void Init_mfilter(){
|
29
|
+
VALUE rb_cMFilter = rb_define_module("MFilter");
|
30
|
+
rb_define_module_function(rb_cMFilter, "filter", RUBY_METHOD_FUNC(rb_m_filter), 3);
|
31
|
+
}
|
32
|
+
}
|
data/lib/mfilter.rb
ADDED
data/mfilter.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/mfilter/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mfilter"
|
7
|
+
spec.version = Mfilter::VERSION
|
8
|
+
spec.authors = ["Murata Mitsuharu"]
|
9
|
+
spec.email = ["hikari.photon+dev@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Function module similar to `filter` in MatLab or Octave."
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
14
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
15
|
+
end
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib", "ext"]
|
19
|
+
spec.extensions = ["ext/mfilter/extconf.rb"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
22
|
+
spec.add_development_dependency "rake-compiler", "~> 1.1.1"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mfilter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Murata Mitsuharu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 12.3.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 12.3.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.1
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- hikari.photon+dev@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/mfilter/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- ext/.gitignore
|
57
|
+
- ext/mfilter/extconf.rb
|
58
|
+
- ext/mfilter/filter.hpp
|
59
|
+
- ext/mfilter/main.cc
|
60
|
+
- lib/mfilter.rb
|
61
|
+
- lib/mfilter/version.rb
|
62
|
+
- mfilter.gemspec
|
63
|
+
homepage:
|
64
|
+
licenses: []
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
- ext
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.3.0
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.2.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Function module similar to `filter` in MatLab or Octave.
|
86
|
+
test_files: []
|