Joseph Redmon
2015-06-25 d1d56a2a72247ef080eb124ce6605f3218ce4295
src/utils.c
@@ -18,8 +18,6 @@
        c = next+1;
    }
    c = copy_string(c);
    next = strchr(c, '_');
    if (next) *next = 0;
    next = strchr(c, '.');
    if (next) *next = 0;
    return c;
@@ -73,11 +71,11 @@
void top_k(float *a, int n, int k, int *index)
{
    int i,j;
    for(j = 0; j < k; ++j) index[j] = 0;
    for(j = 0; j < k; ++j) index[j] = -1;
    for(i = 0; i < n; ++i){
        int curr = i;
        for(j = 0; j < k; ++j){
            if(a[curr] > a[index[j]]){
            if((index[j] < 0) || a[curr] > a[index[j]]){
                int swap = curr;
                curr = index[j];
                index[j] = swap;
@@ -276,10 +274,10 @@
    return variance;
}
float constrain(float a, float max)
float constrain(float min, float max, float a)
{
    if(a > abs(max)) return abs(max);
    if(a < -abs(max)) return -abs(max);
    if (a < min) return min;
    if (a > max) return max;
    return a;
}