X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=svrt.git;a=blobdiff_plain;f=misc.cc;h=7573d5a414eac856240eeac4725209087d15f567;hp=2f766a6978ee3b0cc14f1b6318306e587b848efb;hb=HEAD;hpb=194e1b60502426108c6f6c3cf2e08e95e7a2811d diff --git a/misc.cc b/misc.cc index 2f766a6..7573d5a 100644 --- a/misc.cc +++ b/misc.cc @@ -18,7 +18,7 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with selector. If not, see . + * along with svrt. If not, see . * */ @@ -27,77 +27,3 @@ using namespace std; #include "misc.h" - -char *basename(char *name) { - char *result = name; - while(*name) { - if(*name == '/') result = name + 1; - name++; - } - return result; -} - -char *next_word(char *buffer, char *r, int buffer_size) { - char *s; - s = buffer; - - if(r != 0) { - while((*r == ' ') || (*r == '\t') || (*r == ',')) r++; - if(*r == '"') { - r++; - while((*r != '"') && (*r != '\0') && - (s 0) { - s += n[k] * log(scalar_t(n[k])); - t += n[k]; - } - return (log(t) - s/scalar_t(t))/log(2.0); -} - -void random_permutation(int *val, int nb) { - for(int k = 0; k < nb; k++) val[k] = k; - int i, t; - for(int k = 0; k < nb - 1; k++) { - i = int(drand48() * (nb - k)) + k; - t = val[i]; - val[i] = val[k]; - val[k] = t; - } -} - -void tag_subset(bool *val, int nb_total, int nb_to_tag) { - ASSERT(nb_to_tag <= nb_total); - int index[nb_total]; - random_permutation(index, nb_total); - for(int n = 0; n < nb_total; n++) val[n] = false; - for(int n = 0; n < nb_to_tag; n++) val[index[n]] = true; -} - -int compare_couple(const void *a, const void *b) { - if(((Couple *) a)->value < ((Couple *) b)->value) return -1; - else if(((Couple *) a)->value > ((Couple *) b)->value) return 1; - else return 0; -}