Vector Optimized Library of Kernels 3.1.0
Architecture-tuned implementations of math kernels
volk_32f_s32f_convert_32i

Overview

Converts a floating point number to a 32-bit integer after applying a scaling factor.

Dispatcher Prototype

void volk_32f_s32f_convert_32i(int32_t* outputVector, const float* inputVector, const
float scalar, unsigned int num_points)

Inputs

  • inputVector: the input vector of floats.
  • scalar: The value multiplied against each point in the input buffer.
  • num_points: The number of data points.

Outputs

  • outputVector: The output vector.

Example Convert floats from [-1,1] to integers with a scale of 5 to maintain smallest delta

int N = 10;
unsigned int alignment = volk_get_alignment();
float* increasing = (float*)volk_malloc(sizeof(float)*N, alignment);
int32_t* out = (int32_t*)volk_malloc(sizeof(int32_t)*N, alignment);
for(unsigned int ii = 0; ii < N; ++ii){
increasing[ii] = 2.f * ((float)ii / (float)N) - 1.f;
}
// Normalize by the smallest delta (0.2 in this example)
float scale = 5.f;
volk_32f_s32f_convert_32i(out, increasing, scale, N);
for(unsigned int ii = 0; ii < N; ++ii){
printf("out[%u] = %i\n", ii, out[ii]);
}
volk_free(increasing);
volk_free(out);