chiark / gitweb /
introduce m_over_best and use it instead of computing maxminsize
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Mar 2014 10:48:19 +0000 (10:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Mar 2014 10:49:03 +0000 (10:49 +0000)
XXX makes things slower, perhaps has bug ?!

main.c

diff --git a/main.c b/main.c
index b248631b7b819329ffb8b186cad2030e086f1189..69f56d1a30e8bba421e9e7a7231019a45f08b09d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -101,7 +101,7 @@ static double best;
 static glp_prob *best_prob;
 static AdjWord *best_adjmatrix;
 
-static int n_over_best;
+static int n_over_best, m_over_best;
 static int *weight;
 
 static unsigned printcounter;
@@ -120,6 +120,7 @@ static void progress_eol(void) {
 static void set_best(double new_best) {
   best = new_best;
   n_over_best = floor(n / best);
+  m_over_best = floor(m / best);
 }
 
 /*----- multicore support -----*/
@@ -356,6 +357,7 @@ static void prep(void) {
   setlinebuf(stderr);
   weight = calloc(sizeof(*weight), m);  assert(weight);
   n_over_best = INT_MAX;
+  m_over_best = INT_MAX;
 }
 
 #if 0
@@ -377,8 +379,7 @@ static int count_set_adj_bits(AdjWord w) {
 static int totalfrags;
 
 static bool maxhamweight_ok(void) {
-  double maxminsize = (double)m / maxhamweight;
-  return maxminsize > best;
+  return maxhamweight <= m_over_best;
 }
 
 static bool preconsider_ok(int nwords, bool doprint) {
@@ -390,8 +391,7 @@ static bool preconsider_ok(int nwords, bool doprint) {
   for (i=0, totalfrags=0; i<nwords; i++) {
     int frags = count_set_adj_bits(adjmatrix[i]);
     PRINTF("%"PRADJ" ", adjmatrix[i]);
-    double maxminsize = (double)m / frags;
-    if (maxminsize <= best) {
+    if (frags > m_over_best) {
       PRINTF(" too fine");
       goto out;
     }