hornetseye-fftw3 0.1.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.
data/ext/node.hh ADDED
@@ -0,0 +1,33 @@
1
+ /* HornetsEye - Computer Vision with Ruby
2
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Jan Wedekind
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ #ifndef NODE_HH
17
+ #define NODE_HH
18
+
19
+ #include <boost/smart_ptr.hpp>
20
+ #include "rubyinc.hh"
21
+ #include <string>
22
+
23
+ class Node
24
+ {
25
+ public:
26
+ static VALUE cRubyClass;
27
+ static VALUE mModule;
28
+ static VALUE registerRubyClass( VALUE module );
29
+ static VALUE wrapFFT( VALUE rbSelf, VALUE rbForward );
30
+ static VALUE wrapRFFT( VALUE rbSelf, VALUE rbForward );
31
+ };
32
+
33
+ #endif
data/ext/rubyinc.hh ADDED
@@ -0,0 +1,54 @@
1
+ /* HornetsEye - Computer Vision with Ruby
2
+ Copyright (C) 2006, 2007 Jan Wedekind
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ #ifndef HORNETSEYE_RUBYINC_HH
17
+ #define HORNETSEYE_RUBYINC_HH
18
+
19
+ #ifdef RSHIFT
20
+ #undef RSHIFT
21
+ #endif
22
+
23
+ #define gettimeofday rubygettimeofday
24
+ #define timezone rubygettimezone
25
+ #include <ruby.h>
26
+ // #include <version.h>
27
+ #undef timezone
28
+ #undef gettimeofday
29
+ #ifdef read
30
+ #undef read
31
+ #endif
32
+ #ifdef write
33
+ #undef write
34
+ #endif
35
+ #ifdef RGB
36
+ #undef RGB
37
+ #endif
38
+
39
+ #ifndef RUBY_VERSION_NUMBER
40
+ #define RUBY_VERSION_NUMBER ( RUBY_VERSION_MAJOR * 10000 + \
41
+ RUBY_VERSION_MINOR * 100 + \
42
+ RUBY_VERSION_TEENY )
43
+ #endif
44
+
45
+ #ifndef RUBY_METHOD_FUNC
46
+ #define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
47
+ #endif
48
+
49
+ #ifndef xfree
50
+ #define xfree free
51
+ #endif
52
+
53
+ #endif
54
+
@@ -0,0 +1,52 @@
1
+ # hornetseye-fftw3 - Fourier transforms
2
+ # Copyright (C) 2011 Jan Wedekind
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ module Hornetseye
17
+
18
+ class Node
19
+
20
+ alias_method :orig_fft, :fft
21
+
22
+ def fft( forward = true )
23
+ if forward
24
+ to_type( Hornetseye::COMPLEX( basetype.float ) ).memorise.orig_fft true
25
+ else
26
+ to_type( Hornetseye::COMPLEX( basetype.float ) ).memorise.orig_fft( false ) / size
27
+ end
28
+ end
29
+
30
+ def ifft
31
+ fft false
32
+ end
33
+
34
+ alias_method :orig_rfft, :rfft
35
+
36
+ def rfft( forward = true )
37
+ if forward
38
+ to_type( typecode.float ).memorise.orig_rfft true
39
+ else
40
+ result = to_type( Hornetseye::COMPLEX( basetype.float ) ).memorise.orig_rfft false
41
+ result / result.size
42
+ end
43
+ end
44
+
45
+ def irfft
46
+ rfft false
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
@@ -0,0 +1,18 @@
1
+ # hornetseye-fftw3 - Fourier transforms
2
+ # Copyright (C) 2011 Jan Wedekind
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ require 'multiarray'
17
+ require 'hornetseye-fftw3/node.rb'
18
+
data/test/tc_fftw3.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'test/unit'
2
+ begin
3
+ require 'rubygems'
4
+ rescue LoadError
5
+ end
6
+ Kernel::require 'hornetseye_fftw3'
7
+
8
+ class TC_FFTW3 < Test::Unit::TestCase
9
+
10
+ SC = Hornetseye::SCOMPLEX
11
+ DC = Hornetseye::DCOMPLEX
12
+
13
+ F = Hornetseye::SFLOAT
14
+ D = Hornetseye::DFLOAT
15
+
16
+ def S( *args )
17
+ Hornetseye::Sequence *args
18
+ end
19
+
20
+ def M( *args )
21
+ Hornetseye::MultiArray *args
22
+ end
23
+
24
+ def X( *args )
25
+ Complex *args
26
+ end
27
+
28
+ I = Complex::I
29
+
30
+ def setup
31
+ end
32
+
33
+ def teardown
34
+ end
35
+
36
+ def test_fft
37
+ [ SC, DC ].each do |t|
38
+ s = S( t, 3 )[ 1, I, 3 ]
39
+ u = s.fft.ifft
40
+ s.to_a.zip( u.to_a ).each do |a,b|
41
+ assert_in_delta a.real, b.real, 1.0e-5
42
+ assert_in_delta a.imag, b.imag, 1.0e-5
43
+ end
44
+ end
45
+ end
46
+
47
+ def test_rfft
48
+ [ F, D ].each do |t|
49
+ s = S( t, 4 )[ 2, 3, 5, 7 ]
50
+ u = s.rfft.irfft
51
+ s.to_a.zip( u.to_a ).each do |a,b|
52
+ assert_in_delta a, b, 1.0e-5
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+
data/test/ts_fftw3.rb ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # hornetseye-fftw3 - Fast fourier transforms
3
+ # Copyright (C) 2011 Jan Wedekind
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ require 'tc_fftw3'
18
+
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hornetseye-fftw3
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jan Wedekind
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-02 00:00:00 +00:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: malloc
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 1
31
+ version: "1.1"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: multiarray
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 20
45
+ version: "0.20"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ type: :development
60
+ version_requirements: *id003
61
+ description: This Ruby extension provides bindings for the FFTW3 library.
62
+ email: jan@wedesoft.de
63
+ executables: []
64
+
65
+ extensions:
66
+ - Rakefile
67
+ extra_rdoc_files: []
68
+
69
+ files:
70
+ - Rakefile
71
+ - README.md
72
+ - COPYING
73
+ - .document
74
+ - lib/hornetseye_fftw3_ext.rb
75
+ - lib/hornetseye-fftw3/node.rb
76
+ - ext/init.cc
77
+ - ext/node.cc
78
+ - ext/node.hh
79
+ - ext/error.hh
80
+ - ext/rubyinc.hh
81
+ - test/ts_fftw3.rb
82
+ - test/tc_fftw3.rb
83
+ has_rdoc: yard
84
+ homepage: http://wedesoft.github.com/hornetseye-fftw3/
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --no-private
90
+ require_paths:
91
+ - lib
92
+ - ext
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ requirements: []
110
+
111
+ rubyforge_project: hornetseye
112
+ rubygems_version: 1.3.7
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Fourier transforms
116
+ test_files:
117
+ - test/tc_fftw3.rb