neuro 0.4.1 → 0.4.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.
data/CHANGES CHANGED
@@ -1,3 +1,5 @@
1
+ 2011-05-22 (0.4.2)
2
+ * 1.9.2 compatibility
1
3
  2009-08-27 (0.4.1)
2
4
  * Started using rake-compiler.
3
5
  * Some reorganisation of the repository contents, documentation etc.
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
+ # vim: set filetype=ruby et sw=2 ts=2:
2
+
1
3
  begin
2
4
  require 'rake/gempackagetask'
3
- require 'rake/extensiontask'
4
5
  rescue LoadError
5
6
  end
6
7
 
@@ -21,7 +22,7 @@ task :default => :test
21
22
 
22
23
  desc "Run unit tests"
23
24
  task :test => :compile_ext do
24
- sh 'testrb -Iext:lib tests/test_*.rb'
25
+ sh 'testrb -Iext:lib ./tests/test_*.rb'
25
26
  end
26
27
 
27
28
  desc "Creating documentation"
@@ -51,8 +52,7 @@ task :install => :test do
51
52
  install(src, dst, :verbose => true, :mode => 0644)
52
53
  end
53
54
 
54
- if defined?(Gem) and defined?(Rake::GemPackageTask) and
55
- defined?(Rake::ExtensionTask)
55
+ if defined?(Gem) and defined?(Rake::GemPackageTask)
56
56
  then
57
57
  spec_src = <<-GEM
58
58
  Gem::Specification.new do |s|
@@ -77,7 +77,7 @@ EOF
77
77
 
78
78
  s.author = "Florian Frank"
79
79
  s.email = "flori@ping.de"
80
- s.homepage = "http://neuro.rubyforge.org"
80
+ s.homepage = "http://flori.github.com/#{PKG_NAME}"
81
81
  s.rubyforge_project = '#{PKG_NAME}'
82
82
  end
83
83
  GEM
@@ -94,15 +94,6 @@ EOF
94
94
  pkg.need_tar = true
95
95
  pkg.package_files = PKG_FILES
96
96
  end
97
-
98
- Rake::ExtensionTask.new do |ext|
99
- ext.name = PKG_NAME
100
- ext.gem_spec = spec
101
- ext.cross_compile = true
102
- ext.cross_platform = 'i386-mswin32'
103
- ext.ext_dir = 'ext'
104
- ext.lib_dir = 'lib'
105
- end
106
97
  end
107
98
 
108
99
  desc m = "Writing version information for #{PKG_VERSION}"
@@ -125,7 +116,4 @@ end
125
116
  task :default => [ :version, :gemspec, :test ]
126
117
 
127
118
  desc "Build all gems and archives for a new release."
128
- task :release => [ :clean, :version, :gemspec, :cross, :native, :gem ] do
129
- system "#$0 clean native gem"
130
- system "#$0 clean package"
131
- end
119
+ task :release => [ :clean, :version, :gemspec, :package]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/ext/neuro.c CHANGED
@@ -24,7 +24,7 @@ static ID id_to_f, id_class, id_name;
24
24
  /* Infrastructure */
25
25
 
26
26
  typedef struct NodeStruct {
27
- int number_weights;
27
+ long number_weights;
28
28
  double *weights;
29
29
  double output;
30
30
  } Node;
@@ -46,10 +46,10 @@ typedef struct NetworkStruct {
46
46
 
47
47
  /* Node methods */
48
48
 
49
- static Node *Node_create(int weights)
49
+ static Node *Node_create(long weights)
50
50
  {
51
51
  Node *node;
52
- int i;
52
+ long i;
53
53
  assert(weights > 0);
54
54
  node = ALLOC(Node);
55
55
  MEMZERO(node, Node, 1);
@@ -63,17 +63,17 @@ static Node *Node_create(int weights)
63
63
 
64
64
  static Node *Node_from_hash(VALUE hash)
65
65
  {
66
+ long i, len;
66
67
  Node *node;
67
68
  VALUE weights = rb_hash_aref(hash, SYM("weights"));
68
69
  VALUE output = rb_hash_aref(hash, SYM("output"));
69
- int i, len;
70
70
  Check_Type(output, T_FLOAT);
71
71
  Check_Type(weights, T_ARRAY);
72
- len = RARRAY(weights)->len;
72
+ len = RARRAY_LEN(weights);
73
73
  node = Node_create(len);
74
- node->output = RFLOAT(output)->value;
74
+ node->output = RFLOAT_VALUE(output);
75
75
  for (i = 0; i < len; i++)
76
- node->weights[i] = RFLOAT(rb_ary_entry(weights, i))->value;
76
+ node->weights[i] = RFLOAT_VALUE(rb_ary_entry(weights, i));
77
77
  return node;
78
78
  }
79
79
 
@@ -88,7 +88,7 @@ static void Node_destroy(Node *node)
88
88
  static VALUE Node_to_hash(Node *node)
89
89
  {
90
90
  VALUE result = rb_hash_new(), weights = rb_ary_new2(node->number_weights);
91
- int i;
91
+ long i;
92
92
  rb_hash_aset(result, SYM("output"), rb_float_new(node->output));
93
93
  for (i = 0; i < node->number_weights; i++)
94
94
  rb_ary_store(weights, i, rb_float_new(node->weights[i]));
@@ -138,7 +138,7 @@ static void Network_init_weights(Network *network)
138
138
  network->output_layer[i] = Node_create(network->hidden_size);
139
139
  }
140
140
 
141
- static void Network_debug_error(Network *network, int count, float error, float
141
+ static void Network_debug_error(Network *network, long count, double error, double
142
142
  max_error)
143
143
  {
144
144
  VALUE argv[5];
@@ -192,10 +192,10 @@ static void transform_data(double *data_vector, VALUE data)
192
192
  {
193
193
  int i;
194
194
  VALUE current;
195
- for (i = 0; i < RARRAY(data)->len; i++) {
195
+ for (i = 0; i < RARRAY_LEN(data); i++) {
196
196
  current = rb_ary_entry(data, i);
197
197
  CAST2FLOAT(current);
198
- data_vector[i] = RFLOAT(current)->value;
198
+ data_vector[i] = RFLOAT_VALUE(current);
199
199
  }
200
200
  }
201
201
 
@@ -237,25 +237,25 @@ static VALUE rb_network_learn(VALUE self, VALUE data, VALUE desired, VALUE
237
237
  Network *network;
238
238
  double max_error_float, eta_float, error, sum,
239
239
  *output_delta, *hidden_delta;
240
- int i, j, count;
240
+ long i, j, count;
241
241
 
242
242
  Data_Get_Struct(self, Network, network);
243
243
 
244
244
  Check_Type(data, T_ARRAY);
245
- if (RARRAY(data)->len != network->input_size)
245
+ if (RARRAY_LEN(data) != network->input_size)
246
246
  rb_raise(rb_cNeuroError, "size of data != input_size");
247
247
  transform_data(network->tmp_input, data);
248
248
 
249
249
  Check_Type(desired, T_ARRAY);
250
- if (RARRAY(desired)->len != network->output_size)
250
+ if (RARRAY_LEN(desired) != network->output_size)
251
251
  rb_raise(rb_cNeuroError, "size of desired != output_size");
252
252
  transform_data(network->tmp_output, desired);
253
253
  CAST2FLOAT(max_error);
254
- max_error_float = RFLOAT(max_error)->value;
254
+ max_error_float = RFLOAT_VALUE(max_error);
255
255
  if (max_error_float <= 0) rb_raise(rb_cNeuroError, "max_error <= 0");
256
256
  max_error_float *= 2.0;
257
257
  CAST2FLOAT(eta);
258
- eta_float = RFLOAT(eta)->value;
258
+ eta_float = RFLOAT_VALUE(eta);
259
259
  if (eta_float <= 0) rb_raise(rb_cNeuroError, "eta <= 0");
260
260
 
261
261
  output_delta = ALLOCA_N(double, network->output_size);
@@ -322,12 +322,12 @@ static VALUE rb_network_decide(VALUE self, VALUE data)
322
322
  {
323
323
  Network *network;
324
324
  VALUE result;
325
- int i;
325
+ long i;
326
326
 
327
327
  Data_Get_Struct(self, Network, network);
328
328
 
329
329
  Check_Type(data, T_ARRAY);
330
- if (RARRAY(data)->len != network->input_size)
330
+ if (RARRAY_LEN(data) != network->input_size)
331
331
  rb_raise(rb_cNeuroError, "size of data != input_size");
332
332
  transform_data(network->tmp_input, data);
333
333
  feed;
@@ -515,7 +515,7 @@ static void rb_network_mark(Network *network)
515
515
 
516
516
  static void rb_network_free(Network *network)
517
517
  {
518
- int i;
518
+ long i;
519
519
  for (i = 0; i < network->hidden_size; i++)
520
520
  Node_destroy(network->hidden_layer[i]);
521
521
  MEMZERO(network->hidden_layer, Node*, network->hidden_size);
data/lib/neuro/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Neuro
2
2
  # Neuro version
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/neuro.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'neuro'
3
- s.version = '0.4.1'
3
+ s.version = '0.4.2'
4
4
  s.summary = "Neural Network Extension for Ruby"
5
5
  s.description = <<EOF
6
6
  A Ruby extension that provides a 2-Layer Back Propagation Neural Network, which
@@ -20,6 +20,6 @@ EOF
20
20
 
21
21
  s.author = "Florian Frank"
22
22
  s.email = "flori@ping.de"
23
- s.homepage = "http://neuro.rubyforge.org"
23
+ s.homepage = "http://flori.github.com/neuro"
24
24
  s.rubyforge_project = 'neuro'
25
25
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neuro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 2
10
+ version: 0.4.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Florian Frank
@@ -9,8 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-08-31 00:00:00 +02:00
13
- default_executable:
18
+ date: 2011-05-22 00:00:00 Z
14
19
  dependencies: []
15
20
 
16
21
  description: |
@@ -32,15 +37,13 @@ files:
32
37
  - ext/extconf.rb
33
38
  - ext/neuro.c
34
39
  - install.rb
35
- - lib/neuro.so
36
40
  - lib/neuro/display.rb
37
41
  - lib/neuro/version.rb
38
42
  - neuro.gemspec
39
43
  - tests/test_even_odd.rb
40
44
  - tests/test_parity.rb
41
45
  - doc-main.txt
42
- has_rdoc: true
43
- homepage: http://neuro.rubyforge.org
46
+ homepage: http://flori.github.com/neuro
44
47
  licenses: []
45
48
 
46
49
  post_install_message:
@@ -54,21 +57,27 @@ require_paths:
54
57
  - ext
55
58
  - lib
56
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
57
61
  requirements:
58
62
  - - ">="
59
63
  - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
60
67
  version: "0"
61
- version:
62
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
63
70
  requirements:
64
71
  - - ">="
65
72
  - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
66
76
  version: "0"
67
- version:
68
77
  requirements: []
69
78
 
70
79
  rubyforge_project: neuro
71
- rubygems_version: 1.3.4
80
+ rubygems_version: 1.7.1
72
81
  signing_key:
73
82
  specification_version: 3
74
83
  summary: Neural Network Extension for Ruby
data/lib/neuro.so DELETED
Binary file