fast-fourier 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/compiler.xml +23 -0
- data/.idea/copyright/profiles_settings.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/FastFourier.iml +23 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +4 -0
- data/fast-fourier.gemspec +24 -0
- data/lib/fast-fourier/fast-fourier.rb +124 -0
- data/lib/fast-fourier/version.rb +3 -0
- data/spec/fast-fourier_spec.rb +106 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1cd0ef2fc02524d93db3adf73b5d830335061e3
|
4
|
+
data.tar.gz: 97777a79b8b610a837918ab6d1c8334b26388afa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c0795ebe74323e195be417095d24e71b51727e4e65409cc763f81dc7d5f4225548b5f7296f6e40ad93296137581c29303038230aa6a65ce40b70d12b29fa81a
|
7
|
+
data.tar.gz: 7dacac11f2b754854a1e1ac61900d942468a116e42e9a1b7e1867034aea47a2e33bb88ea9ab8256f964e5920e30fa1c981e97fc03c4dde25da1f426cfe898247
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
.idea/workspace.xml
|
2
|
+
Gemfile.lock
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
## Specific to RubyMotion:
|
15
|
+
.dat*
|
16
|
+
.repl_history
|
17
|
+
build/
|
18
|
+
|
19
|
+
## Documentation cache and generated files:
|
20
|
+
/.yardoc/
|
21
|
+
/_yardoc/
|
22
|
+
/doc/
|
23
|
+
/rdoc/
|
24
|
+
|
25
|
+
## Environment normalisation:
|
26
|
+
/.bundle/
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/.idea/.name
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
FastFourier
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build FastFourier-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install FastFourier-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push FastFourier-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
|
data/.idea/compiler.xml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CompilerConfiguration">
|
4
|
+
<option name="DEFAULT_COMPILER" value="Javac" />
|
5
|
+
<resourceExtensions />
|
6
|
+
<wildcardResourcePatterns>
|
7
|
+
<entry name="!?*.java" />
|
8
|
+
<entry name="!?*.form" />
|
9
|
+
<entry name="!?*.class" />
|
10
|
+
<entry name="!?*.groovy" />
|
11
|
+
<entry name="!?*.scala" />
|
12
|
+
<entry name="!?*.flex" />
|
13
|
+
<entry name="!?*.kt" />
|
14
|
+
<entry name="!?*.clj" />
|
15
|
+
</wildcardResourcePatterns>
|
16
|
+
<annotationProcessing>
|
17
|
+
<profile default="true" name="Default" enabled="false">
|
18
|
+
<processorPath useClasspath="true" />
|
19
|
+
</profile>
|
20
|
+
</annotationProcessing>
|
21
|
+
</component>
|
22
|
+
</project>
|
23
|
+
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="rbenv: 2.1.2" project-jdk-type="RUBY_SDK">
|
4
|
+
<output url="file://$PROJECT_DIR$/out" />
|
5
|
+
</component>
|
6
|
+
</project>
|
7
|
+
|
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/FastFourier.iml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="CompassSettings">
|
4
|
+
<option name="compassSupportEnabled" value="true" />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
7
|
+
<exclude-output />
|
8
|
+
<content url="file://$MODULE_DIR$">
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/lib/fast-fourier" isTestSource="false" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="inheritedJdk" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, rbenv: 2.1.2) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 2.1.2) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, rbenv: 2.1.2) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v2.14.1, rbenv: 2.1.2) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.14.8, rbenv: 2.1.2) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.14.5, rbenv: 2.1.2) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.14.6, rbenv: 2.1.2) [gem]" level="application" />
|
21
|
+
</component>
|
22
|
+
</module>
|
23
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Justin W. Smith
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Justin W Smith
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# FastFourier
|
2
|
+
|
3
|
+
An implementation of the Discrete Fourier Transform.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'FastFourier'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install FastFourier
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fast-fourier/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fast-fourier"
|
8
|
+
spec.version = FastFourier::VERSION
|
9
|
+
spec.authors = ["Justin W Smith"]
|
10
|
+
spec.email = ["justin.w.smith@gmail.com"]
|
11
|
+
spec.description = %q{An implementation of the Cooley-Tukey algorithm for the Discrete Fourier Transform}
|
12
|
+
spec.summary = %q{An implementation of the Cooley-Tukey algorithm for the Discrete Fourier Transform}
|
13
|
+
spec.homepage = "https://github.com/justinwsmith/FastFourier"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
=begin
|
2
|
+
The MIT License (MIT)
|
3
|
+
|
4
|
+
Copyright (c) 2014 Justin W, Smith
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
23
|
+
=end
|
24
|
+
|
25
|
+
module FastFourier
|
26
|
+
|
27
|
+
@@fast_fourier_roots = {
|
28
|
+
Rational(0,1) => Complex(1, 0),
|
29
|
+
Rational(1,4) => Complex(0, 1),
|
30
|
+
Rational(1,2) => Complex(-1, 0),
|
31
|
+
Rational(3,4) => Complex(0, -1),
|
32
|
+
Rational(1,1) => Complex(1, 0)
|
33
|
+
}
|
34
|
+
|
35
|
+
def FastFourier.discrete_fourier(vals, inverse = false)
|
36
|
+
n = vals.length
|
37
|
+
if(n % 2 == 0)
|
38
|
+
dft = :cooley_tukey_dft
|
39
|
+
else
|
40
|
+
dft = :discrete_fourier_slow
|
41
|
+
end
|
42
|
+
|
43
|
+
if inverse
|
44
|
+
case inverse
|
45
|
+
when :conjugate
|
46
|
+
send( dft, vals.map { |x| x.conj } ).map {|x| x.conj / vals.length}
|
47
|
+
when :swap
|
48
|
+
send( dft, vals.map { |x| Complex(x.imag, x.real) } ).map {|x| Complex(x.imag, x.real) / vals.length}
|
49
|
+
else
|
50
|
+
send( dft, [vals[0]] + vals[1..-1].reverse).map{|x| x / vals.length}
|
51
|
+
end
|
52
|
+
else
|
53
|
+
send( dft, vals)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class <<self
|
58
|
+
alias_method(:dft, :discrete_fourier)
|
59
|
+
end
|
60
|
+
|
61
|
+
# This is a self-inverse variation of the discrete fourier transform
|
62
|
+
def FastFourier.discrete_involutary(vals)
|
63
|
+
n = vals.length
|
64
|
+
if(n % 2 == 0)
|
65
|
+
dft = :cooley_tukey_dft
|
66
|
+
else
|
67
|
+
dft = :discrete_fourier_slow
|
68
|
+
end
|
69
|
+
|
70
|
+
result = send( dft, vals.map { |x| x.conj } ).map {|x| x / Math.sqrt(vals.length) }
|
71
|
+
|
72
|
+
result[0...n]
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def FastFourier.root_of_unity(den, num = 1)
|
78
|
+
key = Rational(num, den) % 1
|
79
|
+
if ans = @@fast_fourier_roots[key]
|
80
|
+
ans
|
81
|
+
else
|
82
|
+
angle = 2*Math::PI * key
|
83
|
+
@@fast_fourier_roots[key] = Complex(Math.cos(angle), Math.sin(angle))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def FastFourier.cooley_tukey_dft(vals)
|
88
|
+
if vals.size == 1
|
89
|
+
vals
|
90
|
+
else
|
91
|
+
n = vals.length
|
92
|
+
if(n % 2 == 0) # if n is not a power of 2
|
93
|
+
dft = :cooley_tukey_dft
|
94
|
+
else
|
95
|
+
dft = :discrete_fourier_slow
|
96
|
+
end
|
97
|
+
vals_even = send( dft, (0...n).step(2).map{|i| vals[i]})
|
98
|
+
vals_odd = send( dft, (1...n).step(2).map{|i| vals[i]})
|
99
|
+
|
100
|
+
ret_vals = Array.new(n)
|
101
|
+
|
102
|
+
(0...(n/2)).each do |i|
|
103
|
+
ei = vals_even[i]
|
104
|
+
oi = vals_odd[i]
|
105
|
+
npri = root_of_unity(n, i).conj
|
106
|
+
oink = npri * oi
|
107
|
+
ret_vals[i] = (ei + oink)
|
108
|
+
ret_vals[i+n/2] = (ei - oink)
|
109
|
+
end
|
110
|
+
ret_vals
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def FastFourier.discrete_fourier_slow(vals, inverse=false)
|
115
|
+
npr = root_of_unity(vals.length)
|
116
|
+
(0...(vals.length)).map do |i|
|
117
|
+
ary = (0...(vals.length)).map do |j|
|
118
|
+
vals[j] * npr ** (-1*i*j)
|
119
|
+
end
|
120
|
+
ary.inject(:+)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require_relative '../lib/FastFourier/fast-fourier.rb'
|
2
|
+
|
3
|
+
EPSILON = (2.0)**(-12.0)
|
4
|
+
module FFTHelper
|
5
|
+
def FFTHelper.equal x, y
|
6
|
+
if [x, y].any? {|a| a.is_a? Complex}
|
7
|
+
(x - y).magnitude < EPSILON
|
8
|
+
else
|
9
|
+
(x - y) < EPSILON
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
include FastFourier
|
15
|
+
|
16
|
+
describe FastFourier do
|
17
|
+
describe "root_of_unity" do
|
18
|
+
2.times do
|
19
|
+
den = 1 + rand(100)
|
20
|
+
num = rand(den)
|
21
|
+
|
22
|
+
ans = FastFourier.root_of_unity(den, num)
|
23
|
+
specify "#{num}th root raised to #{num}th power should be idempotent" do
|
24
|
+
#puts "#{ans**den}"
|
25
|
+
expect((ans**den - 1).magnitude).to be < EPSILON
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
inputs = (0..6).map {|x| (0...(2**x)).map{rand(1000)} } + (5..23).step(8).map {|x| (0...x).map{rand(1000)}}
|
31
|
+
|
32
|
+
describe "dft" do
|
33
|
+
(0...inputs.length).each do |i|
|
34
|
+
|
35
|
+
angle = (2 * Math::PI) / inputs[i].length
|
36
|
+
npr = Complex(Math.cos(angle), Math.sin(angle))
|
37
|
+
result = FastFourier.dft(inputs[i])
|
38
|
+
expected_result = (0...(inputs[i].length)).map do |j|
|
39
|
+
(0...(inputs[i].length)).map {|k| inputs[i][k] * npr ** (-1*j*k)}.inject(:+)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "for input of length #{inputs[i].length}" do
|
43
|
+
|
44
|
+
specify "the result should also be of length #{inputs[i].length}" do
|
45
|
+
expect(result.length).to be == inputs[i].length
|
46
|
+
end
|
47
|
+
|
48
|
+
(0...(result.length)).each do |j|
|
49
|
+
specify "index #{j} should match the DFT definition" do
|
50
|
+
expect(result[j]).to be_within(EPSILON).of(expected_result[j])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "the result should be invertable." do
|
55
|
+
inv = FastFourier.dft(result, true)
|
56
|
+
#puts "#{inversion} <=> #{inputs[i]}"
|
57
|
+
|
58
|
+
(0...(result.length)).each do |j|
|
59
|
+
specify "result index #{j} did not match input" do
|
60
|
+
expect(inv[j]).to be_within(EPSILON).of(inputs[i][j])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
inv_c = FastFourier.dft(result, :conjugate)
|
65
|
+
#puts "#{inv_c} <=> #{inputs[i]}"
|
66
|
+
|
67
|
+
(0...(result.length)).each do |j|
|
68
|
+
specify "conjugate result index #{j} did not match input" do
|
69
|
+
expect(inv_c[j]).to be_within(EPSILON).of(inputs[i][j])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
inv_s = FastFourier.dft(result, :swap)
|
74
|
+
#puts "#{inv_s} <=> #{inputs[i]}"
|
75
|
+
|
76
|
+
(0...(result.length)).each do |j|
|
77
|
+
specify "swap result index #{j} did not match input" do
|
78
|
+
expect(inv_s[j]).to be_within(EPSILON).of(inputs[i][j])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "discrete_involutary" do
|
87
|
+
|
88
|
+
(0...inputs.length).each do |i|
|
89
|
+
result = FastFourier.discrete_involutary(inputs[i])
|
90
|
+
describe "for input of length #{inputs[i].length}" do
|
91
|
+
specify "the result should also be of length #{inputs[i].length}" do
|
92
|
+
expect(result.length).to be == inputs[i].length
|
93
|
+
end
|
94
|
+
describe "the result should be invertable." do
|
95
|
+
inv = FastFourier.discrete_involutary(result)
|
96
|
+
(0...(result.length)).each do |j|
|
97
|
+
specify "conjugate result index #{j} did not match input" do
|
98
|
+
expect(inv[j]).to be_within(EPSILON).of(inputs[i][j])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fast-fourier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin W Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: An implementation of the Cooley-Tukey algorithm for the Discrete Fourier
|
56
|
+
Transform
|
57
|
+
email:
|
58
|
+
- justin.w.smith@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".idea/.name"
|
65
|
+
- ".idea/.rakeTasks"
|
66
|
+
- ".idea/compiler.xml"
|
67
|
+
- ".idea/copyright/profiles_settings.xml"
|
68
|
+
- ".idea/encodings.xml"
|
69
|
+
- ".idea/misc.xml"
|
70
|
+
- ".idea/modules.xml"
|
71
|
+
- ".idea/scopes/scope_settings.xml"
|
72
|
+
- ".idea/vcs.xml"
|
73
|
+
- FastFourier.iml
|
74
|
+
- Gemfile
|
75
|
+
- LICENSE
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- fast-fourier.gemspec
|
80
|
+
- lib/fast-fourier/fast-fourier.rb
|
81
|
+
- lib/fast-fourier/version.rb
|
82
|
+
- spec/fast-fourier_spec.rb
|
83
|
+
homepage: https://github.com/justinwsmith/FastFourier
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.2.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: An implementation of the Cooley-Tukey algorithm for the Discrete Fourier
|
107
|
+
Transform
|
108
|
+
test_files:
|
109
|
+
- spec/fast-fourier_spec.rb
|