ffts 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/README.md +7 -0
- data/ext/ffts/extconf.rb +36 -0
- data/ext/ffts/ffts.c +88 -0
- data/lib/ffts/version.rb +3 -0
- data/lib/ffts.rb +5 -0
- data.tar.gz.sig +2 -0
- metadata +99 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cbeea7345418afbc3f3f317a2726a44767056e5
|
4
|
+
data.tar.gz: fb1001eb4c979c18ba5961c829cfb9cb64088c7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56092d7d86e2f0b0813f2206ac11be5dbaa2f8672e31929f868416e764753fdd08dfd59c1fda15d81aec74581e3f4e50021af36d950abcfd4de97b34bf178714
|
7
|
+
data.tar.gz: 964aceab4d83fb854dbb0baa464e83354b98927953f354938fb4b8b67986fecfa1e5b43e2006a16469256e48989d39c15989c34fe37df65d82228f2965644589
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/README.md
ADDED
data/ext/ffts/extconf.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'pry-byebug'
|
3
|
+
|
4
|
+
header_dirs = [
|
5
|
+
# First search /opt/local for macports
|
6
|
+
'/opt/local/include',
|
7
|
+
|
8
|
+
# Then search /usr/local for people that installed from source
|
9
|
+
'/usr/local/include',
|
10
|
+
|
11
|
+
# Finally fall back to /usr
|
12
|
+
'/usr/include',
|
13
|
+
]
|
14
|
+
|
15
|
+
lib_dirs = [
|
16
|
+
# First search /opt/local for macports
|
17
|
+
'/opt/local/lib',
|
18
|
+
|
19
|
+
# Then search /usr/local for people that installed from source
|
20
|
+
'/usr/local/lib',
|
21
|
+
|
22
|
+
# Finally fall back to /usr
|
23
|
+
'/usr/lib',
|
24
|
+
]
|
25
|
+
|
26
|
+
dir_config('ffts', header_dirs, lib_dirs)
|
27
|
+
|
28
|
+
unless find_header('ffts/ffts.h')
|
29
|
+
abort "FFTS is missing. Please install FFTS."
|
30
|
+
end
|
31
|
+
|
32
|
+
unless find_library('ffts', 'ffts_free', *lib_dirs)
|
33
|
+
abort "FFTS library cannot be found. Please install FFTS."
|
34
|
+
end
|
35
|
+
|
36
|
+
create_makefile 'ffts/ffts'
|
data/ext/ffts/ffts.c
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include <stdio.h>
|
3
|
+
#include <ffts/ffts.h>
|
4
|
+
|
5
|
+
// Declare variables.
|
6
|
+
VALUE mFFTS;
|
7
|
+
VALUE cPlan;
|
8
|
+
VALUE cCPlan;
|
9
|
+
|
10
|
+
static VALUE
|
11
|
+
ffts_plan_initialize(VALUE self, VALUE rb_frames, VALUE rb_sign) {
|
12
|
+
ffts_plan_t *plan;
|
13
|
+
|
14
|
+
size_t size = RARRAY_LEN(rb_frames);
|
15
|
+
if (size % 2 != 0) {
|
16
|
+
rb_raise(rb_eRuntimeError, "Frames must be a power of 2.");
|
17
|
+
return Qnil;
|
18
|
+
}
|
19
|
+
|
20
|
+
int sign_v = NUM2INT(rb_sign);
|
21
|
+
if (sign_v != -1 && sign_v != 1) {
|
22
|
+
rb_raise(rb_eRuntimeError, "Sign must be 1 or -1.");
|
23
|
+
return Qnil;
|
24
|
+
}
|
25
|
+
|
26
|
+
plan = ffts_init_1d(size, sign_v);
|
27
|
+
|
28
|
+
VALUE rb_plan = Data_Wrap_Struct(cCPlan, NULL, ffts_free, plan);
|
29
|
+
|
30
|
+
rb_funcall(self, rb_intern("n="), 1, INT2NUM(size));
|
31
|
+
rb_funcall(self, rb_intern("frames="), 1, rb_frames);
|
32
|
+
rb_funcall(self, rb_intern("sign="), 1, rb_sign);
|
33
|
+
rb_funcall(self, rb_intern("plan="), 1, rb_plan);
|
34
|
+
|
35
|
+
return self;
|
36
|
+
}
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
ffts_plan_execute(VALUE self) {
|
40
|
+
|
41
|
+
|
42
|
+
VALUE rb_plan = rb_funcall(self, rb_intern("plan"), 0);
|
43
|
+
VALUE rb_frames = rb_funcall(self, rb_intern("frames"), 0);
|
44
|
+
VALUE rb_n = rb_funcall(self, rb_intern("n"), 0);
|
45
|
+
|
46
|
+
ffts_plan_t *plan;
|
47
|
+
Data_Get_Struct(rb_plan, ffts_plan_t, plan);
|
48
|
+
|
49
|
+
int n = NUM2INT(rb_n);
|
50
|
+
if (n % 2 != 0) {
|
51
|
+
return Qnil;
|
52
|
+
}
|
53
|
+
|
54
|
+
size_t alloc_length = 2 * n * sizeof(float);
|
55
|
+
float __attribute__ ((aligned(32))) *input = valloc(alloc_length);
|
56
|
+
float __attribute__ ((aligned(32))) *output = valloc(alloc_length);
|
57
|
+
|
58
|
+
for (int i = 0; i < n; ++i) {
|
59
|
+
input[i] = (float)NUM2DBL(RARRAY_AREF(rb_frames, i));
|
60
|
+
}
|
61
|
+
|
62
|
+
ffts_execute(plan, input, output);
|
63
|
+
|
64
|
+
VALUE rb_output = rb_ary_new();
|
65
|
+
for (int i = 0; i < n; ++i) {
|
66
|
+
rb_ary_push(rb_output, DBL2NUM(output[i]));
|
67
|
+
}
|
68
|
+
|
69
|
+
free(input);
|
70
|
+
free(output);
|
71
|
+
|
72
|
+
return rb_output;
|
73
|
+
}
|
74
|
+
|
75
|
+
void
|
76
|
+
Init_ffts(void) {
|
77
|
+
mFFTS = rb_const_get(rb_cObject, rb_intern("FFTS"));
|
78
|
+
cPlan = rb_define_class_under(mFFTS, "Plan", rb_cObject);
|
79
|
+
cCPlan = rb_define_class_under(mFFTS, "CPlan", rb_cObject);
|
80
|
+
|
81
|
+
rb_define_method(cPlan, "initialize", ffts_plan_initialize, 2);
|
82
|
+
rb_define_method(cPlan, "execute", ffts_plan_execute, 0);
|
83
|
+
|
84
|
+
rb_define_attr(cPlan, "n", 1, 1);
|
85
|
+
rb_define_attr(cPlan, "frames", 1, 1);
|
86
|
+
rb_define_attr(cPlan, "sign", 1, 1);
|
87
|
+
rb_define_attr(cPlan, "plan", 1, 1);
|
88
|
+
}
|
data/lib/ffts/version.rb
ADDED
data/lib/ffts.rb
ADDED
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan Rasband
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApkYW5y
|
14
|
+
YXNiYW5kMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
15
|
+
b20wHhcNMTUxMDI2MjEzNDA3WhcNMTYxMDI1MjEzNDA3WjBBMRMwEQYDVQQDDApk
|
16
|
+
YW5yYXNiYW5kMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
17
|
+
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWgl4NOeTSBFB0
|
18
|
+
yD1qyiADyWmGOZmDkeTYkbv+65+ns5nz20je9ee0R0y8BPtVe8oUS9wMzhdduXjh
|
19
|
+
9wV3cCstBriqgAXqbv9twYYFdjc4FXUAVILtDeIZ47T9UwCAWyeZHaycSGn5PkIM
|
20
|
+
Ti4o33TfrSiEP66N+h/6B14RCyAtpf2zjvjZT/XsN6hR0toYinogH0KXBLJIRUdg
|
21
|
+
TQDQLrNtuMBzzzlP2d3HbqQhGaPn73Wf3mkz+ltVnUOdhK3Fv+xN8B/hOvosUfTN
|
22
|
+
m9Y9t97hBtsOE4zXXFd9A8hEHrHcOrgnOOjl8Kvoz0mKJGXq0rby/DGDz2ct+Elk
|
23
|
+
iiN+RTOJAgMBAAGjezB5MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
24
|
+
BBTdIBAg/2cHgQSFreX06uYBVAiGBjAfBgNVHREEGDAWgRRkYW5yYXNiYW5kQGdt
|
25
|
+
YWlsLmNvbTAfBgNVHRIEGDAWgRRkYW5yYXNiYW5kQGdtYWlsLmNvbTANBgkqhkiG
|
26
|
+
9w0BAQUFAAOCAQEAB19wUzc7lO1sBUWNcnVXCtgB6/8ThHMFzhcbq1d4Cb6q4Quj
|
27
|
+
uUmfuwh8tmRX9TRMOn+oHnV88g849+nr/GhxF/2SdDykBYu2W5Yi+7tSuwxpuF7A
|
28
|
+
u6mFZ6eZb28uoMGwS76Yl1PSp0FIz9htECRL4+EvCXeoBnoCCNwBUiaN9JfqIn8p
|
29
|
+
doY1LTSooEKZ2zMTwfMIOifrJ9tlnfKTwPRgxOotxz9poQXQCiMBktyHcp0eoj+y
|
30
|
+
BiDRWkycv2ZreORGVsxZ+ch02vmRX9UqxIKp5++g/hJ5k+LJ4frajmbhgq5FNPFe
|
31
|
+
O1WpSI6ffxV1ZjyK6iS5qG0Rdze3zqFTKnPpeg==
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake-compiler
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.9.0
|
42
|
+
type: :development
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.9.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: pry-byebug
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.2'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
description: A native extension for the FFTS library.
|
64
|
+
email: danrasband@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions:
|
67
|
+
- ext/ffts/extconf.rb
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- README.md
|
71
|
+
- ext/ffts/extconf.rb
|
72
|
+
- ext/ffts/ffts.c
|
73
|
+
- lib/ffts.rb
|
74
|
+
- lib/ffts/version.rb
|
75
|
+
homepage: https://github.com/danrasband/ruby-ffts
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.5.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: FFTS
|
99
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|