OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-link-grammar commits / 267dada

estimate_log2_table_size(): Avoid warning on conversion to/from double
(I would like to clean up implicit conversions.)
267dadabefc41dd9e6c7a2758e7edef2568f6b18
by ampli <amirpli@gmail.com> · 2024-05-29T23:59:35.000Z

Changed files (2) +5 -4

link-grammar/parse/count.c +1 -1
……@@ -40,7 +40,7 @@ typedef uint8_t WordIdx_m; /* Storage representation of word index */
4040const bool ENABLE_WORD_SKIP_VECTOR = true;
4141const bool ENABLE_MATCH_LIST_CACHE = true;
4242const bool ENABLE_TABLE_LRCNT = true; // Also controls the above two caches.
43const bool USE_TABLE_TRACON = true; // The table is always maintained.
43const bool USE_TABLE_TRACON = false; // The table is always maintained.
4444const bool USE_PSEUDOCOUNT = true; // Controls only the non-cyclic solutions.
4545
4646typedef struct Table_tracon_s Table_tracon;
link-grammar/parse/extract-links.c +4 -3
……@@ -157,7 +157,8 @@ static void record_choice(
157157static int estimate_log2_table_size(Sentence sent)
158158{
159159 /* Size estimate based on measurements (see #1402) */
160 double lscale = log2(sent->num_disjuncts + 1.0) - 0.5 * log2(sent->length);
160 double lscale = log2((double)sent->num_disjuncts + 1.0) -
161 0.5 * log2((double)sent->length);
161162 double lo_est = lscale + 4.0;
162163 double hi_est = 1.5 * lscale;
163164 double dj_est = fmax(lo_est, hi_est);
……@@ -166,10 +167,10 @@ static int estimate_log2_table_size(Sentence sent)
166167 * pex->Pset_bucket_pool is almost exactly equal to the num elts
167168 * issued for sent->Table_tracon_pool. This provides a better
168169 * estimate when parsing with MST, when the above is too low. */
169 double ntracon = pool_num_elements_issued(sent->Table_tracon_pool);
170 double ntracon = (double)pool_num_elements_issued(sent->Table_tracon_pool);
170171 double ltra = log2(ntracon) + 1.0; // + 1.0 because floor()
171172
172 int log2_table_size = floor(fmax(dj_est, ltra));
173 int log2_table_size = (int)floor(fmax(dj_est, ltra));
173174
174175 // Enforce min and max sizes.
175176 if (log2_table_size < 4) log2_table_size = 4;