ruby-fann 1.4.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c291587d1ebb0faf402b6d8dfa9e7629c5fc02e14b43c138c641945b899f434
4
- data.tar.gz: ea97a950c60a26d63dbaecc12bf79ac3ecd8ed9b4a27d12e87c39add9228a5c2
3
+ metadata.gz: d60f815b69ebd06c43817b1804684b72474f9a6d7c02f43a7d057ba631baeba3
4
+ data.tar.gz: 958d4cac668983cbc533dbbb4cf4fca6001d359ca5b6e011c691070bccec24aa
5
5
  SHA512:
6
- metadata.gz: a309c2c124032e56f5532608d3979f4c039902a8ab31f05422c8385b8975baca1dce3596c7ffa8b0a2f125d4f78691699509a6bb2ecbb22278ff8d0a032e2fca
7
- data.tar.gz: 4a3e11465e2d660bb09442cb7dab7ef572c21aea8427b18fc6bdb70afad986e213703cac02b43bed9fa4d59d0e40f9958e91610c6261ff56e87aa340d85edc84
6
+ metadata.gz: 1552c4475c755a926e54dc031a6279837e55246289f22275ca6c2ea44303c58891cdb094bcf082155ea8f683c393f38d82e43be96915aa084b88a3e50572630f
7
+ data.tar.gz: cd557118462f5ca697d036f9ed8ef40ab35a87bacfe7b870a754dd37527a20c5a6f8d48f8d6da0a5f24a127e019f4030a52205e0f9a772ac04756296b93c065b
@@ -1,112 +1,112 @@
1
1
  #include "ruby.h"
2
2
  #include "ruby_compat.h"
3
3
 
4
- FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary2(
5
- unsigned int num_data,
6
- unsigned int num_input,
7
- unsigned long num_output)
4
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_create_train_from_rb_ary2(
5
+ unsigned int num_data,
6
+ unsigned int num_input,
7
+ unsigned long num_output)
8
8
  {
9
- return 0;
9
+ return 0;
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
- FANN_EXTERNAL struct fann_train_data * FANN_API fann_create_train_from_rb_ary(
17
- VALUE inputs,
18
- VALUE outputs
19
- )
16
+ FANN_EXTERNAL struct fann_train_data *FANN_API fann_create_train_from_rb_ary(
17
+ VALUE inputs,
18
+ VALUE outputs)
20
19
  {
21
20
  unsigned int i, j;
22
21
  fann_type *data_input, *data_output;
23
22
  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
-
28
- if(data == NULL) {
23
+
24
+ long num_input = RARRAY_LEN(RARRAY_PTR(inputs)[0]);
25
+ long num_output = RARRAY_LEN(RARRAY_PTR(outputs)[0]);
26
+ long num_data = RARRAY_LEN(inputs);
27
+
28
+ if (data == NULL)
29
+ {
29
30
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
30
31
  return NULL;
31
32
  }
32
33
 
33
- fann_init_error_data((struct fann_error *) data);
34
+ fann_init_error_data((struct fann_error *)data);
34
35
 
35
- data->num_data = num_data;
36
- data->num_input = num_input;
36
+ data->num_data = num_data;
37
+ data->num_input = num_input;
37
38
  data->num_output = num_output;
38
-
39
- data->input = (fann_type **) calloc(num_data, sizeof(fann_type *));
40
- if(data->input == NULL)
39
+ data->input = (fann_type **)calloc(num_data, sizeof(fann_type *));
40
+ if (data->input == NULL)
41
41
  {
42
42
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
43
43
  fann_destroy_train(data);
44
44
  return NULL;
45
45
  }
46
46
 
47
- data->output = (fann_type **) calloc(num_data, sizeof(fann_type *));
48
- if(data->output == NULL)
47
+ data->output = (fann_type **)calloc(num_data, sizeof(fann_type *));
48
+ if (data->output == NULL)
49
49
  {
50
50
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
51
51
  fann_destroy_train(data);
52
52
  return NULL;
53
53
  }
54
-
55
- data_input = (fann_type *) calloc(num_input * num_data, sizeof(fann_type));
56
- if(data_input == NULL)
54
+ data_input = (fann_type *)calloc(num_input * num_data, sizeof(fann_type));
55
+ if (data_input == NULL)
57
56
  {
58
57
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
59
58
  fann_destroy_train(data);
60
59
  return NULL;
61
60
  }
62
61
 
63
- data_output = (fann_type *) calloc(num_output * num_data, sizeof(fann_type));
64
- if(data_output == NULL)
62
+ data_output = (fann_type *)calloc(num_output * num_data, sizeof(fann_type));
63
+ if (data_output == NULL)
65
64
  {
66
65
  fann_error(NULL, FANN_E_CANT_ALLOCATE_MEM);
67
66
  fann_destroy_train(data);
68
67
  return NULL;
69
68
  }
70
69
 
71
- VALUE inputs_i, outputs_i;
72
- for(i = 0; i != num_data; i++)
73
- {
74
- data->input[i] = data_input;
75
- data_input += num_input;
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)
81
- {
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);
86
- }
87
-
88
- if(RARRAY_LEN(outputs_i) != num_output)
89
- {
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);
94
- }
95
-
96
-
97
- for(j = 0; j != num_input; j++)
98
- {
99
- data->input[i][j]=NUM2DBL(RARRAY_PTR(inputs_i)[j]);
100
- }
101
-
102
- data->output[i] = data_output;
103
- data_output += num_output;
104
-
105
- for(j = 0; j != num_output; j++)
106
- {
107
- data->output[i][j]=NUM2DBL(RARRAY_PTR(outputs_i)[j]);
108
- }
109
- }
110
-
70
+ VALUE inputs_i, outputs_i;
71
+ for (i = 0; i != num_data; i++)
72
+ {
73
+ data->input[i] = data_input;
74
+ data_input += num_input;
75
+
76
+ inputs_i = RARRAY_PTR(inputs)[i];
77
+ outputs_i = RARRAY_PTR(outputs)[i];
78
+
79
+ if (RARRAY_LEN(inputs_i) != num_input)
80
+ {
81
+ rb_raise(
82
+ rb_eRuntimeError,
83
+ "Number of inputs at [%d] is inconsistent: (%du != %d)",
84
+ i, RARRAY_LEN(inputs_i)),
85
+ num_input;
86
+ }
87
+
88
+ if (RARRAY_LEN(outputs_i) != num_output)
89
+ {
90
+ rb_raise(
91
+ rb_eRuntimeError,
92
+ "Number of outputs at [%d] is inconsistent: (%d != %d)",
93
+ i, RARRAY_LEN(outputs_i)),
94
+ num_output;
95
+ }
96
+
97
+ for (j = 0; j != num_input; j++)
98
+ {
99
+ data->input[i][j] = NUM2DBL(RARRAY_PTR(inputs_i)[j]);
100
+ }
101
+
102
+ data->output[i] = data_output;
103
+ data_output += num_output;
104
+
105
+ for (j = 0; j != num_output; j++)
106
+ {
107
+ data->output[i][j] = NUM2DBL(RARRAY_PTR(outputs_i)[j]);
108
+ }
109
+ }
110
+
111
111
  return data;
112
112
  }