ruby-fann 1.4.2 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c291587d1ebb0faf402b6d8dfa9e7629c5fc02e14b43c138c641945b899f434
4
- data.tar.gz: ea97a950c60a26d63dbaecc12bf79ac3ecd8ed9b4a27d12e87c39add9228a5c2
3
+ metadata.gz: 1513ab175dd525a96a3846565c6b54a2d5bf44af679144a4f7e877dd8e948e03
4
+ data.tar.gz: 9942ab1a6cd7112ec21fa4d7912f8f72e62a18ab429948cc507c73a8af5efb73
5
5
  SHA512:
6
- metadata.gz: a309c2c124032e56f5532608d3979f4c039902a8ab31f05422c8385b8975baca1dce3596c7ffa8b0a2f125d4f78691699509a6bb2ecbb22278ff8d0a032e2fca
7
- data.tar.gz: 4a3e11465e2d660bb09442cb7dab7ef572c21aea8427b18fc6bdb70afad986e213703cac02b43bed9fa4d59d0e40f9958e91610c6261ff56e87aa340d85edc84
6
+ metadata.gz: 5b0a6b6909f6d19b005454dfddf77570493ddf3618c7b51e6fd36c99b09bfa3858b489cfca80829253f1c1ed79c953cbae21b6f4a24eddd34cd37d31920d529d
7
+ data.tar.gz: 8776e0c70509d821e032b2e9b1bf7c0a323609e3bf69a7cd294ebbb192c57236c06e5cffcb869f79291d3fabe5ef17f6553cd078419f88283cdff05f33ff17d4
@@ -10,21 +10,23 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary2(
10
10
  }
11
11
 
12
12
  /*
13
- * Copied from fann_create_train_from_callback/file & modified to ease
13
+ * Copied from fann_create_train_from_callback/file & modified to ease
14
14
  * allocating from ruby arrays:
15
15
  */
16
16
  FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
17
- VALUE inputs,
18
- VALUE outputs
17
+ VALUE inputs,
18
+ VALUE outputs
19
19
  )
20
20
  {
21
21
  unsigned int i, j;
22
22
  fann_type *data_input, *data_output;
23
23
  struct fann_train_data *data = (struct fann_train_data *)malloc(sizeof(struct fann_train_data));
24
- unsigned int num_input = NUM2UINT(RARRAY_LEN(RARRAY_PTR(inputs)[0]));
25
- unsigned int num_output = NUM2UINT(RARRAY_LEN(RARRAY_PTR(outputs)[0]));
26
- unsigned int num_data = NUM2UINT(RARRAY_LEN(inputs));
27
-
24
+
25
+ long num_input = RARRAY_LEN(RARRAY_PTR(inputs)[0]);
26
+ long num_output = RARRAY_LEN(RARRAY_PTR(outputs)[0]);
27
+ long num_data = RARRAY_LEN(inputs);
28
+
29
+
28
30
  if(data == NULL) {
29
31
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
30
32
  return NULL;
@@ -35,7 +37,6 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
35
37
  data->num_data = num_data;
36
38
  data->num_input = num_input;
37
39
  data->num_output = num_output;
38
-
39
40
  data->input = (fann_type **) calloc(num_data, sizeof(fann_type *));
40
41
  if(data->input == NULL)
41
42
  {
@@ -51,7 +52,6 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
51
52
  fann_destroy_train(data);
52
53
  return NULL;
53
54
  }
54
-
55
55
  data_input = (fann_type *) calloc(num_input * num_data, sizeof(fann_type));
56
56
  if(data_input == NULL)
57
57
  {
@@ -74,26 +74,26 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
74
74
  data->input[i] = data_input;
75
75
  data_input += num_input;
76
76
 
77
- inputs_i = NUM2UINT(RARRAY_PTR(inputs)[i]);
78
- outputs_i = NUM2UINT(RARRAY_PTR(inputs)[i]);
79
-
80
- if(RARRAY_LEN(inputs_i) != num_input)
77
+ inputs_i = RARRAY_PTR(inputs)[i];
78
+ outputs_i = RARRAY_PTR(outputs)[i];
79
+
80
+ if(RARRAY_LEN(inputs_i) != num_input)
81
81
  {
82
82
  rb_raise (
83
- rb_eRuntimeError,
84
- "Number of inputs at [%d] is inconsistent: (%d != %d)",
85
- i,NUM2UINT(RARRAY_LEN(inputs_i)), num_input);
83
+ rb_eRuntimeError,
84
+ "Number of inputs at [%d] is inconsistent: (%du != %d)",
85
+ i,RARRAY_LEN(inputs_i)), num_input;
86
86
  }
87
-
88
- if(RARRAY_LEN(outputs_i) != num_output)
87
+
88
+ if(RARRAY_LEN(outputs_i) != num_output)
89
89
  {
90
90
  rb_raise (
91
- rb_eRuntimeError,
92
- "Number of outputs at [%d] is inconsistent: (%d != %d)",
93
- i, NUM2UINT(RARRAY_LEN(outputs_i)), num_output);
91
+ rb_eRuntimeError,
92
+ "Number of outputs at [%d] is inconsistent: (%d != %d)",
93
+ i, RARRAY_LEN(outputs_i)), num_output;
94
94
  }
95
-
96
-
95
+
96
+
97
97
  for(j = 0; j != num_input; j++)
98
98
  {
99
99
  data->input[i][j]=NUM2DBL(RARRAY_PTR(inputs_i)[j]);
@@ -101,12 +101,12 @@ FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
101
101
 
102
102
  data->output[i] = data_output;
103
103
  data_output += num_output;
104
-
104
+
105
105
  for(j = 0; j != num_output; j++)
106
106
  {
107
107
  data->output[i][j]=NUM2DBL(RARRAY_PTR(outputs_i)[j]);
108
108
  }
109
109
  }
110
-
110
+
111
111
  return data;
112
112
  }