ffts 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cbeea7345418afbc3f3f317a2726a44767056e5
4
- data.tar.gz: fb1001eb4c979c18ba5961c829cfb9cb64088c7d
3
+ metadata.gz: 10f347bd4abb1ff4718df56c1d5bb03e2a445419
4
+ data.tar.gz: 1ba1ed3c8241c42cce9aee993fef4b8b8690b45a
5
5
  SHA512:
6
- metadata.gz: 56092d7d86e2f0b0813f2206ac11be5dbaa2f8672e31929f868416e764753fdd08dfd59c1fda15d81aec74581e3f4e50021af36d950abcfd4de97b34bf178714
7
- data.tar.gz: 964aceab4d83fb854dbb0baa464e83354b98927953f354938fb4b8b67986fecfa1e5b43e2006a16469256e48989d39c15989c34fe37df65d82228f2965644589
6
+ metadata.gz: 73a5833e4ba612e2497300175881ebd2eb25447c35fec9aca22ee25412b3f88c8b03e72d776af9d00fb2c67076812d4ec49c213dadb7d6462d544851357ef91f
7
+ data.tar.gz: 15e31ca601b38e7f65478b3b85d6ab39fcbf1e9cc301fe3e38cb450f167fcda955565aeb994974364f94ef0dc08f2f4ec9d3c5a3bbbb38224e4cbfee199cb17e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- I6�hSc��grJ��;�����
2
- ^t:�8lN{L��̎���m���U��8���1��0��=�0jz��rH��as�{�*y.�\sXv��8.�q&�͡�p����e`��(�@� �����g�^>���c�� ��2���H�Z�lA����bS��]%l��@����\�h�`ws,qMhU���[G(�uӼ����ҶQ(#�LC\A:���x��l��2��-5���D5:�S%�΍�9�:s�X&��ş]����
1
+ S5%񟂐� ei�C�|�q��D7����rd�`�Q�|�SA'�:$7N'��q�z1c=�o4n�ܣ<h\_G�oñDFE��D6�#��MhU<�ׯQo��%l������p"�~���.S-��Cf>���OP���
2
+ ?���H�#��(, f�`y
3
+ ��z�����h�m6L�`l�e��1�=���5ջ�V�����d�
data/ext/ffts/ffts.c CHANGED
@@ -1,5 +1,6 @@
1
- #include <ruby.h>
2
1
  #include <stdio.h>
2
+ #include <stdbool.h>
3
+ #include <ruby.h>
3
4
  #include <ffts/ffts.h>
4
5
 
5
6
  // Declare variables.
@@ -7,12 +8,14 @@ VALUE mFFTS;
7
8
  VALUE cPlan;
8
9
  VALUE cCPlan;
9
10
 
11
+ bool is_power_of_two(size_t num);
12
+
10
13
  static VALUE
11
14
  ffts_plan_initialize(VALUE self, VALUE rb_frames, VALUE rb_sign) {
12
15
  ffts_plan_t *plan;
13
16
 
14
- size_t size = RARRAY_LEN(rb_frames);
15
- if (size % 2 != 0) {
17
+ size_t n = RARRAY_LEN(rb_frames);
18
+ if (!is_power_of_two(n)) {
16
19
  rb_raise(rb_eRuntimeError, "Frames must be a power of 2.");
17
20
  return Qnil;
18
21
  }
@@ -23,11 +26,11 @@ ffts_plan_initialize(VALUE self, VALUE rb_frames, VALUE rb_sign) {
23
26
  return Qnil;
24
27
  }
25
28
 
26
- plan = ffts_init_1d(size, sign_v);
29
+ plan = ffts_init_1d(n, sign_v);
27
30
 
28
31
  VALUE rb_plan = Data_Wrap_Struct(cCPlan, NULL, ffts_free, plan);
29
32
 
30
- rb_funcall(self, rb_intern("n="), 1, INT2NUM(size));
33
+ rb_funcall(self, rb_intern("n="), 1, INT2NUM(n));
31
34
  rb_funcall(self, rb_intern("frames="), 1, rb_frames);
32
35
  rb_funcall(self, rb_intern("sign="), 1, rb_sign);
33
36
  rb_funcall(self, rb_intern("plan="), 1, rb_plan);
@@ -46,8 +49,8 @@ ffts_plan_execute(VALUE self) {
46
49
  ffts_plan_t *plan;
47
50
  Data_Get_Struct(rb_plan, ffts_plan_t, plan);
48
51
 
49
- int n = NUM2INT(rb_n);
50
- if (n % 2 != 0) {
52
+ size_t n = NUM2INT(rb_n);
53
+ if (!is_power_of_two(n)) {
51
54
  return Qnil;
52
55
  }
53
56
 
@@ -72,6 +75,11 @@ ffts_plan_execute(VALUE self) {
72
75
  return rb_output;
73
76
  }
74
77
 
78
+ bool
79
+ is_power_of_two(size_t num) {
80
+ return num != 0 && (num & (num - 1)) == 0;
81
+ }
82
+
75
83
  void
76
84
  Init_ffts(void) {
77
85
  mFFTS = rb_const_get(rb_cObject, rb_intern("FFTS"));
data/lib/ffts/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FFTS
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Rasband
@@ -12,23 +12,23 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApkYW5y
14
14
  YXNiYW5kMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
15
- b20wHhcNMTUxMDI2MjEzNDA3WhcNMTYxMDI1MjEzNDA3WjBBMRMwEQYDVQQDDApk
15
+ b20wHhcNMTUxMDI2MjIxNjI3WhcNMTYxMDI1MjIxNjI3WjBBMRMwEQYDVQQDDApk
16
16
  YW5yYXNiYW5kMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
17
- FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCWgl4NOeTSBFB0
18
- yD1qyiADyWmGOZmDkeTYkbv+65+ns5nz20je9ee0R0y8BPtVe8oUS9wMzhdduXjh
19
- 9wV3cCstBriqgAXqbv9twYYFdjc4FXUAVILtDeIZ47T9UwCAWyeZHaycSGn5PkIM
20
- Ti4o33TfrSiEP66N+h/6B14RCyAtpf2zjvjZT/XsN6hR0toYinogH0KXBLJIRUdg
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l1PSp0FIz9htECRL4+EvCXeoBnoCCNwBUiaN9JfqIn8p
29
- doY1LTSooEKZ2zMTwfMIOifrJ9tlnfKTwPRgxOotxz9poQXQCiMBktyHcp0eoj+y
30
- BiDRWkycv2ZreORGVsxZ+ch02vmRX9UqxIKp5++g/hJ5k+LJ4frajmbhgq5FNPFe
31
- O1WpSI6ffxV1ZjyK6iS5qG0Rdze3zqFTKnPpeg==
26
+ 9w0BAQUFAAOCAQEAcgIu1pWJWj7E5noRhfTAVYX3+i3xJiW484bky20n0VSQEX2T
27
+ s8ENyBhI0y1Y/1BUbWSfhZtKmSJvKjWEVT4NipbFcKod4lrnBruizQ9aTqj9x1B5
28
+ 6KJZl3ppvwqbvSxNxjaOeVO+rGpiRO/zdNLDAJPPuehJOZSyPOILGA2hy5PnOmJE
29
+ 237mrci4Axp8xDT9Qp7ZfgPdp1ZDTdEMXCjb4ihgJiN4cFoZs7IgAQCzyYF3soTL
30
+ 5dFUvDBq46FYLdfJJHzAZrez850ti1TKMYo7ABWoFVLP6yBMquIYU4arv5pQFX7Q
31
+ bRWJCvjhK7kCrH7LGywoYctBEz0OfIYZ9URmVw==
32
32
  -----END CERTIFICATE-----
33
33
  date: 2015-10-26 00:00:00.000000000 Z
34
34
  dependencies:
metadata.gz.sig CHANGED
Binary file