From: Francois Fleuret Date: Sat, 29 Dec 2012 10:31:33 +0000 (+0100) Subject: Cleaned up a bit implicit conversions. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=e777319f3c213198e574dd3cac2de1aeac6bfbbf;p=mtp.git Cleaned up a bit implicit conversions. --- diff --git a/Makefile b/Makefile index edb6eb6..c502771 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ifeq ($(PROFILE),yes) PROFILE_FLAG = -pg endif -CXXFLAGS = -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(VERBOSE_FLAG) +CXXFLAGS = -Wconversion -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(VERBOSE_FLAG) all: mtp mtp_example mtp_stress_test diff --git a/mtp_example.cc b/mtp_example.cc index c1f6778..9e8db82 100644 --- a/mtp_example.cc +++ b/mtp_example.cc @@ -35,9 +35,9 @@ using namespace std; scalar_t noisy_score(scalar_t true_score, scalar_t erroneous_score, scalar_t score_noise, scalar_t flip_noise) { if(drand48() < flip_noise) { - return erroneous_score + score_noise * (2.0 * drand48() - 1.0); + return erroneous_score + score_noise * (2.0f * scalar_t(drand48()) - 1.0f); } else { - return true_score + score_noise * (2.0 * drand48() - 1.0); + return true_score + score_noise * (2.0f * scalar_t(drand48()) - 1.0f); } } @@ -84,8 +84,8 @@ int main(int argc, char **argv) { // Then, we specify for every location and time step what is the // detection score there. - scalar_t flip_noise = 0.05; - scalar_t score_noise = 0.0; + scalar_t flip_noise = 0.05f; + scalar_t score_noise = 0.0f; // We first put a background noise, with negative scores at every // location. diff --git a/mtp_graph.cc b/mtp_graph.cc index 0fe3cf0..fcdcfed 100644 --- a/mtp_graph.cc +++ b/mtp_graph.cc @@ -216,7 +216,7 @@ void MTPGraph::compute_dp_ranks() { for(int k = 0; k < _nb_vertices; k++) { v = _vertices + k; for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) { - tv = e->terminal_vertex - _vertices; + tv = int(e->terminal_vertex - _vertices); nb_predecessors[tv]++; } } @@ -235,7 +235,7 @@ void MTPGraph::compute_dp_ranks() { v = _vertices + without_predecessors[l]; v->distance_from_source = rank; for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) { - tv = e->terminal_vertex - _vertices; + tv = int(e->terminal_vertex - _vertices); nb_predecessors[tv]--; ASSERT(nb_predecessors[tv] >= 0); if(nb_predecessors[tv] == 0) { @@ -466,13 +466,13 @@ int MTPGraph::retrieve_one_path(Edge *e, Path *path) { int l = 0, nb_occupied_next; if(path) { - path->nodes[l++] = e->origin_vertex - _vertices; + path->nodes[l++] = int(e->origin_vertex - _vertices); path->length = e->length; } else l++; while(e->terminal_vertex != _sink) { if(path) { - path->nodes[l++] = e->terminal_vertex - _vertices; + path->nodes[l++] = int(e->terminal_vertex - _vertices); path->length += e->length; } else l++; @@ -497,7 +497,7 @@ int MTPGraph::retrieve_one_path(Edge *e, Path *path) { } if(path) { - path->nodes[l++] = e->terminal_vertex - _vertices; + path->nodes[l++] = int(e->terminal_vertex - _vertices); path->length += e->length; } else l++; diff --git a/mtp_stress_test.cc b/mtp_stress_test.cc index 7fa7a64..590e807 100644 --- a/mtp_stress_test.cc +++ b/mtp_stress_test.cc @@ -57,7 +57,7 @@ int main(int argc, char **argv) { for(int t = 0; t < nb_time_steps; t++) { for(int l = 0; l < nb_locations; l++) { - tracker->detection_scores[t][l] = drand48() - 0.95; + tracker->detection_scores[t][l] = scalar_t(drand48()) - 0.95f; } }