correlation 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. data/LICENSE +27 -0
  2. data/gemspec +17 -14
  3. data/lib/correlation.rb +5 -7
  4. data/rakefile +3 -0
  5. metadata +35 -10
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2009, Ralf Mueller (stark.dreamdetective@googlemail.com)
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/gemspec CHANGED
@@ -1,20 +1,23 @@
1
1
  require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
- s.name = "correlation"
5
- s.version = "0.0.1"
6
- s.author = "Ralf M�ller"
7
- s.email = "stark.dreamdetective@gmail.com"
8
- s.homepage = "http://extcsv.rubyforge.org/correlation"
9
- s.platform = Gem::Platform::RUBY
10
- s.summary = "Extension of GSL: Compute correaltion of 2 datasets"
11
- candidates = Dir.glob("lib/*.rb") + [ "rakefile", "gemspec"]
12
- s.files = candidates.delete_if do |item|
13
- item.include?(".hg") || item.include?("doc")
14
- end
15
- s.require_path = "lib"
16
- s.test_files = Dir.glob("test/test_*.rb")
17
- s.has_rdoc = true
4
+ s.name = 'correlation'
5
+ s.version = '0.0.2'
6
+ s.date = Time.new.to_s
7
+ s.author = 'Ralf Mueller'
8
+ s.email = 'stark.dreamdetective@gmail.com'
9
+ s.homepage = 'http://extcsv.rubyforge.org/correlation'
10
+ s.platform = Gem::Platform::RUBY
11
+ s.rubyforge_project = "extcsv"
12
+ s.add_dependency('gsl')
13
+ s.summary = 'Extension of GSL: Compute correaltion of 2 datasets'
14
+ candidates = Dir.glob('lib/*.rb') + [ 'rakefile', 'gemspec','LICENSE']
15
+ s.files = candidates.delete_if do |item|
16
+ item.include?('www') || item.include?('pkg') || item.include?('doc')
17
+ end
18
+ s.require_path = 'lib'
19
+ s.test_files = Dir.glob('test/test_*.rb')
20
+ s.has_rdoc = true
18
21
  end
19
22
 
20
23
  # vim:ft=ruby
data/lib/correlation.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "rbgsl"
1
+ require "gsl"
2
2
 
3
3
  # This Extension of the GNU Scientific Library bindings by Yoshiki Tsunesada
4
4
  # (http://rb-gsl.rubyforge.org) provides the computation of the correlation of two
5
5
  # GSL::Vectors. It is implemented as a method of a GSL::Vector for most easy
6
- # usage.
6
+ # usage. see project page: http://rubyforge.org/projects/extcsv
7
7
  class GSL::Vector
8
8
 
9
9
  # Follow the usual definition, e.g. from Sheriff and Geldart "Exploitation
@@ -19,8 +19,7 @@ class GSL::Vector
19
19
  end
20
20
 
21
21
  # predefine result vector
22
- correlation = GSL::Vector.alloc(1)
23
- correlation.shift
22
+ correlation = GSL::Vector.alloc(2*size+1)
24
23
 
25
24
  # Alternate definition, which is actually the opposite direction of the definition
26
25
  # (0...size).each {|i|
@@ -29,12 +28,11 @@ class GSL::Vector
29
28
  # (1...size).each {|i|
30
29
  # correlation << self[i..size-1]*other[0...size-i].col
31
30
  # }
32
-
33
31
  (0...size).each {|i|
34
- correlation << self[-i-1..-1]*other[0..i].col
32
+ correlation[0] = (self.to_a[-i-1..-1].to_gv)*(other.to_a[0..i].to_gv.col)
35
33
  }
36
34
  (1...size).each {|i|
37
- correlation << self[0...size-i]*other[i..size-1].col
35
+ correlation[size+i] = (self.to_a[0...size-i].to_gv)*(other.to_a[i..size-1].to_gv.col)
38
36
  }
39
37
 
40
38
  [GSL::Vector.linspace(-size+1, size-1, 2*size-1) , correlation]
data/rakefile CHANGED
@@ -14,6 +14,8 @@ def filename_to_sym(filename)
14
14
  File.basename(filename,File.extname(filename)).to_sym
15
15
  end
16
16
 
17
+ # ====================================================================
18
+ task :default => []
17
19
  # ====================================================================
18
20
  # TEST TASKS
19
21
  test_tasks = {
@@ -90,6 +92,7 @@ task :tags do
90
92
  com = "rtags --vi -f tags lib/*.rb"
91
93
  system(com)
92
94
  end
95
+
93
96
  #
94
97
  #
95
98
  # vim:ft=ruby
metadata CHANGED
@@ -1,18 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: correlation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
5
10
  platform: ruby
6
11
  authors:
7
- - "Ralf M\xFCller"
12
+ - Ralf Mueller
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-03-24 00:00:00 +01:00
17
+ date: 2010-11-16 00:36:11 +01:00
13
18
  default_executable:
14
- dependencies: []
15
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: gsl
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
16
33
  description:
17
34
  email: stark.dreamdetective@gmail.com
18
35
  executables: []
@@ -25,31 +42,39 @@ files:
25
42
  - lib/correlation.rb
26
43
  - rakefile
27
44
  - gemspec
45
+ - LICENSE
46
+ - test/test_correlation.rb
28
47
  has_rdoc: true
29
48
  homepage: http://extcsv.rubyforge.org/correlation
49
+ licenses: []
50
+
30
51
  post_install_message:
31
52
  rdoc_options: []
32
53
 
33
54
  require_paths:
34
55
  - lib
35
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
36
58
  requirements:
37
59
  - - ">="
38
60
  - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
39
63
  version: "0"
40
- version:
41
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
42
66
  requirements:
43
67
  - - ">="
44
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
45
71
  version: "0"
46
- version:
47
72
  requirements: []
48
73
 
49
- rubyforge_project:
50
- rubygems_version: 1.2.0
74
+ rubyforge_project: extcsv
75
+ rubygems_version: 1.3.7
51
76
  signing_key:
52
- specification_version: 2
77
+ specification_version: 3
53
78
  summary: "Extension of GSL: Compute correaltion of 2 datasets"
54
79
  test_files:
55
80
  - test/test_correlation.rb