Vectorized type conversion for autocorrelation I have a simple task as part of a larger autocorrelation DSP system - to convert from signed 16-bit integer audio samples to floating-point. This part is quite self-contained:
#include &lt;cblas.h&gt;

typedef int16_t sample_t;

void consume(const sample_t *samples, int N, int rate)
{
    float *input = calloc(N, sizeof(float)),
         *output = calloc(N, sizeof(float));
    assert(input);
    assert(output);
    
    for (int i = 0; i &lt; N; i++)
        input[i] = (float)samples[i];

    // BLAS processing of 'input'

    for (int i = 0; i &lt; N; i++)
    {
        output[i] = cblas_sdot(  // Standard CBLAS call
            N-i,     // N
            input,   // X
            1,       // incX
            input+i, // Y
            1        // incY
        );
    }
}

Due to external constraints - the hardware only supports S16_LE samples - ALSA cannot do this conversion for me, nor can cblas accept integer types; so I'm stuck doing this myself. I've not found anything in gsl or cblas that runs vectorized type conversion.
I'm also not in love with having to loop over a level-1 dot product, but I've not been able to find a good way in BLAS to represent a single level-2 (matrix-vector) multiplication where the matrix is just a heavily-aliased single vector.
Is there a better way to do this?
If this code goes into production then the asserts for the success of calloc() will be optimized out of the code if the code is optimized. Prefer if statements with calls to fprintf(stderr,.
The parameter rate is never used, this can lead to maintenance errors in the future.
For maintenance reasons the ability of someone else to understand the code I would suggest using &amp;input[i] rather than input+ in the function call.