Skip to content

Commit

Permalink
fixed compilation on 64 bit OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
Nissen Steffen authored and Nissen Steffen committed Jan 23, 2012
1 parent 975a124 commit c263110
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
28 changes: 14 additions & 14 deletions src/fann.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_sparse_array(float connection_ra
printf("creating network with connection rate %f\n", connection_rate);
printf("input\n");
printf(" layer : %d neurons, 1 bias\n",
ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1);
(int)(ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1));
#endif

num_neurons_in = ann->num_input;
Expand Down Expand Up @@ -455,7 +455,7 @@ FANN_EXTERNAL struct fann *FANN_API fann_create_shortcut_array(unsigned int num_
printf("creating fully shortcut connected network.\n");
printf("input\n");
printf(" layer : %d neurons, 1 bias\n",
ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1);
(int)(ann->first_layer->last_neuron - ann->first_layer->first_neuron - 1));
#endif

num_neurons_in = ann->num_input;
Expand Down Expand Up @@ -1119,8 +1119,8 @@ FANN_EXTERNAL void FANN_API fann_print_connections(struct fann *ann)
neurons[ann->connections[i] - ann->first_layer->first_neuron] = (char)('A' + value);
}
}
printf("L %3d / N %4d %s\n", layer_it - ann->first_layer,
neuron_it - ann->first_layer->first_neuron, neurons);
printf("L %3d / N %4d %s\n", (int)(layer_it - ann->first_layer),
(int)(neuron_it - ann->first_layer->first_neuron), neurons);
}
}

Expand Down Expand Up @@ -1221,12 +1221,12 @@ FANN_EXTERNAL void FANN_API fann_print_parameters(struct fann *ann)
if(ann->network_type == FANN_NETTYPE_SHORTCUT)
{
printf(" Hidden layer :%4d neurons, 0 bias\n",
layer_it->last_neuron - layer_it->first_neuron);
(int)(layer_it->last_neuron - layer_it->first_neuron));
}
else
{
printf(" Hidden layer :%4d neurons, 1 bias\n",
layer_it->last_neuron - layer_it->first_neuron - 1);
(int)(layer_it->last_neuron - layer_it->first_neuron - 1));
}
}
printf("Output layer :%4d neurons\n", ann->num_output);
Expand Down Expand Up @@ -1376,7 +1376,7 @@ FANN_EXTERNAL void FANN_API fann_get_connection_array(struct fann *ann, struct f
struct fann_neuron *first_neuron;
struct fann_layer *layer_it;
struct fann_neuron *neuron_it;
unsigned int index;
unsigned int idx;
unsigned int source_index;
unsigned int destination_index;

Expand All @@ -1392,7 +1392,7 @@ FANN_EXTERNAL void FANN_API fann_get_connection_array(struct fann *ann, struct f
/* for each neuron */
for(neuron_it = layer_it->first_neuron; neuron_it != layer_it->last_neuron; neuron_it++){
/* for each connection */
for (index = neuron_it->first_con; index < neuron_it->last_con; index++){
for (idx = neuron_it->first_con; idx < neuron_it->last_con; idx++){
/* Assign the source, destination and weight */
connections->from_neuron = ann->connections[source_index] - first_neuron;
connections->to_neuron = destination_index;
Expand All @@ -1409,11 +1409,11 @@ FANN_EXTERNAL void FANN_API fann_get_connection_array(struct fann *ann, struct f
FANN_EXTERNAL void FANN_API fann_set_weight_array(struct fann *ann,
struct fann_connection *connections, unsigned int num_connections)
{
unsigned int index;
unsigned int idx;

for (index = 0; index < num_connections; index++) {
fann_set_weight(ann, connections[index].from_neuron,
connections[index].to_neuron, connections[index].weight);
for (idx = 0; idx < num_connections; idx++) {
fann_set_weight(ann, connections[idx].from_neuron,
connections[idx].to_neuron, connections[idx].weight);
}
}

Expand All @@ -1423,7 +1423,7 @@ FANN_EXTERNAL void FANN_API fann_set_weight(struct fann *ann,
struct fann_neuron *first_neuron;
struct fann_layer *layer_it;
struct fann_neuron *neuron_it;
unsigned int index;
unsigned int idx;
unsigned int source_index;
unsigned int destination_index;

Expand All @@ -1441,7 +1441,7 @@ FANN_EXTERNAL void FANN_API fann_set_weight(struct fann *ann,
/* for each neuron */
for(neuron_it = layer_it->first_neuron; neuron_it != layer_it->last_neuron; neuron_it++){
/* for each connection */
for (index = neuron_it->first_con; index < neuron_it->last_con; index++){
for (idx = neuron_it->first_con; idx < neuron_it->last_con; idx++){
/* If the source and destination neurons match, assign the weight */
if (((int)from_neuron == ann->connections[source_index] - first_neuron) &&
(to_neuron == destination_index))
Expand Down
12 changes: 6 additions & 6 deletions src/fann_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int fann_save_internal_fd(struct fann *ann, FILE * conf, const char *configurati
#endif

/* Save network parameters */
fprintf(conf, "num_layers=%u\n", ann->last_layer - ann->first_layer);
fprintf(conf, "num_layers=%d\n", (int)(ann->last_layer - ann->first_layer));
fprintf(conf, "learning_rate=%f\n", ann->learning_rate);
fprintf(conf, "connection_rate=%f\n", ann->connection_rate);
fprintf(conf, "network_type=%u\n", ann->network_type);
Expand Down Expand Up @@ -239,7 +239,7 @@ int fann_save_internal_fd(struct fann *ann, FILE * conf, const char *configurati
for(layer_it = ann->first_layer; layer_it != ann->last_layer; layer_it++)
{
/* the number of neurons in the layers (in the last layer, there is always one too many neurons, because of an unused bias) */
fprintf(conf, "%u ", layer_it->last_neuron - layer_it->first_neuron);
fprintf(conf, "%d ", (int)(layer_it->last_neuron - layer_it->first_neuron));
}
fprintf(conf, "\n");

Expand Down Expand Up @@ -319,18 +319,18 @@ int fann_save_internal_fd(struct fann *ann, FILE * conf, const char *configurati
if(save_as_fixed)
{
/* save the connection "(source weight) " */
fprintf(conf, "(%u, %d) ",
connected_neurons[i] - first_neuron,
fprintf(conf, "(%d, %d) ",
(int)(connected_neurons[i] - first_neuron),
(int) floor((weights[i] * fixed_multiplier) + 0.5));
}
else
{
/* save the connection "(source weight) " */
fprintf(conf, "(%u, " FANNPRINTF ") ", connected_neurons[i] - first_neuron, weights[i]);
fprintf(conf, "(%d, " FANNPRINTF ") ", (int)(connected_neurons[i] - first_neuron), weights[i]);
}
#else
/* save the connection "(source weight) " */
fprintf(conf, "(%u, " FANNPRINTF ") ", connected_neurons[i] - first_neuron, weights[i]);
fprintf(conf, "(%d, " FANNPRINTF ") ", (int)(connected_neurons[i] - first_neuron), weights[i]);
#endif

}
Expand Down

0 comments on commit c263110

Please sign in to comment.