### Fixed a bug in distance().

`Signed-off-by: wmb <wmb@teknik.io>`
tags/v0.1.0
wmb 7 ay önce
ebeveyn
işleme
fe3be644b8
1 değiştirilmiş dosya ile 8 ekleme ve 10 silme
1. 8
10
main.c

#### + 8 - 10 main.cDosyayı Görüntüle

 @@ -16,7 +16,7 @@ typedef int *solution; /* Functions */ double distance(const vector *u, const vector *v); double distance(const vector u, const vector v); bool trouver_solution_initiale(void); bool solution_valide(const solution s); void print_solution(const solution s, const char *name); @@ -24,8 +24,8 @@ vector *centres_gravite(const solution s); int solution_voisine(solution *dest, const solution src); double fonction_objective(const solution s); static double calculer_inter(vector *cgs); static double calculer_intra(const solution s, vector *cgs); static double calculer_inter(const vector *cgs); static double calculer_intra(const solution s, const vector *cgs); /* Variables */ @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); } double distance(const vector *u, const vector *v) double distance(const vector u, const vector v) { size_t i = 0; double sum = 0.0; @@ -287,19 +287,18 @@ double fonction_objective(const solution s) return inter - intra; } static double calculer_inter(vector *cgs) static double calculer_inter(const vector *cgs) { double inter = 0.0; int cluster; for (cluster = 0; cluster < n_clusters; cluster++) inter += distance((const vector *) cgs[n_clusters], (const vector *) cgs[cluster]); inter += distance(cgs[n_clusters], cgs[cluster]); return inter / (double) n_clusters; } static double calculer_intra(const solution s, vector *cgs) static double calculer_intra(const solution s, const vector *cgs) { double intra = 0.0; int cluster; @@ -314,8 +313,7 @@ static double calculer_intra(const solution s, vector *cgs) continue; ++vectors_in_this_cluster; intra_for_this_cluster += distance((const vector *) cgs[cluster], (const vector *) benchmark_data[i]); intra_for_this_cluster += distance(cgs[cluster], benchmark_data[i]); } intra += intra_for_this_cluster / (double) vectors_in_this_cluster;