After profiling my code, I noticed most time is in the do-while area of this snippet:
        uint16_t* vec=NULL; 
        double* data=NULL;
        double a,b;
        int len;
        size_t ret;
        // ... initialization/malloc as necessary
        ret = fread(vec, uint16_t, len, ptr);
        do {
            data[len-1] = ((double)vec[len-1])*a + b;
        } while (--len);
        // ... continue 
Is there any way to improve efficiency by elimination array indexing? In the C language, is it possible to do type conversion within fread? Hypothetically speaking, is there a way to work with this (completely incorrect pseudo code follows, but you get the idea...):
        ret = fread((double)data, uint16_t, len, ptr);
        do {
            data[len-1] *= a;
            data[len-1] += b;
        } while (--len);
