fwt 0.1.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/fwt.gemspec +4 -3
- data/tests/test_fwt.rb +62 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46983f7b164a5ba936747fd3b8a143e45e65b78e
|
4
|
+
data.tar.gz: 6c092163b85d8bb1f2a9515dd4fbe4f07153b9ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 817725fed18aa2dfd3bc91719ab57ea1d99606c8816f3de015448afc7c66d0e98c09b38e8c82cdfa949efb5b2ff9d97b2ffe801a0465a0cc37460a70eb3995e5
|
7
|
+
data.tar.gz: 6a9f1e54075aa06bb01f72cceaf9870b07c10225b2df3ec541bc86ae1ebac7bd164a3bd9120aec6d3051ebe191ff5c3a803740d42fc6598fd41329324e35b551
|
data/fwt.gemspec
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
_VERSION = "0.1
|
2
|
+
_VERSION = "0.2.1"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fwt"
|
6
6
|
s.version = _VERSION
|
7
7
|
s.date = "2013-03-03"
|
8
|
-
s.summary = "Fast
|
8
|
+
s.summary = "Fast Walsh Transform native Ruby implementations."
|
9
9
|
s.email = "pjs@alum.mit.edu"
|
10
|
-
s.description = "Implements Hadamard- and sequency-ordered
|
10
|
+
s.description = "Implements Hadamard- and sequency-ordered Fast Walsh Transforms as extensions of class Array."
|
11
11
|
s.author = "Paul J Sanchez"
|
12
12
|
s.files = %w[
|
13
13
|
fwt.gemspec
|
14
14
|
lgpl.txt
|
15
15
|
lib/fwt.rb
|
16
|
+
tests/test_fwt.rb
|
16
17
|
]
|
17
18
|
s.required_ruby_version = '>= 1.8.1'
|
18
19
|
s.license = 'LGPL'
|
data/tests/test_fwt.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fwt'
|
5
|
+
|
6
|
+
class FWT_test < Test::Unit::TestCase
|
7
|
+
def test_hadamard
|
8
|
+
assert_equal [1,0,0,0,0,0,0,0].hadamard, [1, 1, 1, 1, 1, 1, 1, 1]
|
9
|
+
assert_equal [0,1,0,0,0,0,0,0].hadamard, [1, -1, 1, -1, 1, -1, 1, -1]
|
10
|
+
assert_equal [0,0,1,0,0,0,0,0].hadamard, [1, 1, -1, -1, 1, 1, -1, -1]
|
11
|
+
assert_equal [0,0,0,1,0,0,0,0].hadamard, [1, -1, -1, 1, 1, -1, -1, 1]
|
12
|
+
assert_equal [0,0,0,0,1,0,0,0].hadamard, [1, 1, 1, 1, -1, -1, -1, -1]
|
13
|
+
assert_equal [0,0,0,0,0,1,0,0].hadamard, [1, -1, 1, -1, -1, 1, -1, 1]
|
14
|
+
assert_equal [0,0,0,0,0,0,1,0].hadamard, [1, 1, -1, -1, -1, -1, 1, 1]
|
15
|
+
assert_equal [0,0,0,0,0,0,0,1].hadamard, [1, -1, -1, 1, -1, 1, 1, -1]
|
16
|
+
assert_equal [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1].sequency,
|
17
|
+
[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]
|
18
|
+
assert_raise Exception do # non-power-of-2 array
|
19
|
+
[0,0,1].hadamard
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_sequency
|
24
|
+
assert_equal [1,0,0,0,0,0,0,0].sequency, [1, 1, 1, 1, 1, 1, 1, 1]
|
25
|
+
assert_equal [0,1,0,0,0,0,0,0].sequency, [1, 1, 1, 1, -1, -1, -1, -1]
|
26
|
+
assert_equal [0,0,1,0,0,0,0,0].sequency, [1, 1, -1, -1, -1, -1, 1, 1]
|
27
|
+
assert_equal [0,0,0,1,0,0,0,0].sequency, [1, 1, -1, -1, 1, 1, -1, -1]
|
28
|
+
assert_equal [0,0,0,0,1,0,0,0].sequency, [1, -1, -1, 1, 1, -1, -1, 1]
|
29
|
+
assert_equal [0,0,0,0,0,1,0,0].sequency, [1, -1, -1, 1, -1, 1, 1, -1]
|
30
|
+
assert_equal [0,0,0,0,0,0,1,0].sequency, [1, -1, 1, -1, -1, 1, -1, 1]
|
31
|
+
assert_equal [0,0,0,0,0,0,0,1].sequency, [1, -1, 1, -1, 1, -1, 1, -1]
|
32
|
+
assert_equal [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0].sequency,
|
33
|
+
[1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1]
|
34
|
+
assert_raise Exception do # non-power-of-2 array
|
35
|
+
[0,0,1].sequency
|
36
|
+
end
|
37
|
+
assert_raise Exception do # empty array
|
38
|
+
[].sequency
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_power_of_2
|
43
|
+
assert_true 1.power_of_2?
|
44
|
+
assert_true 2.power_of_2?
|
45
|
+
assert_true 4.power_of_2?
|
46
|
+
assert_true 8.power_of_2?
|
47
|
+
assert_true 16.power_of_2?
|
48
|
+
assert_true (2**32).power_of_2?
|
49
|
+
assert_true (2**500).power_of_2?
|
50
|
+
assert_false 0.power_of_2?
|
51
|
+
assert_false 3.power_of_2?
|
52
|
+
assert_false 5.power_of_2?
|
53
|
+
assert_false 7.power_of_2?
|
54
|
+
assert_false (-1).power_of_2?
|
55
|
+
assert_false (-2).power_of_2?
|
56
|
+
assert_false (-3).power_of_2?
|
57
|
+
assert_false (-4).power_of_2?
|
58
|
+
assert_false (2**32 - 1).power_of_2?
|
59
|
+
assert_false (2**500 - 1).power_of_2?
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul J Sanchez
|
@@ -10,8 +10,8 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Implements Hadamard- and sequency-ordered
|
14
|
-
Array.
|
13
|
+
description: Implements Hadamard- and sequency-ordered Fast Walsh Transforms as extensions
|
14
|
+
of class Array.
|
15
15
|
email: pjs@alum.mit.edu
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- fwt.gemspec
|
21
21
|
- lgpl.txt
|
22
22
|
- lib/fwt.rb
|
23
|
+
- tests/test_fwt.rb
|
23
24
|
homepage:
|
24
25
|
licenses:
|
25
26
|
- LGPL
|
@@ -43,5 +44,5 @@ rubyforge_project:
|
|
43
44
|
rubygems_version: 2.0.0
|
44
45
|
signing_key:
|
45
46
|
specification_version: 4
|
46
|
-
summary: Fast
|
47
|
+
summary: Fast Walsh Transform native Ruby implementations.
|
47
48
|
test_files: []
|