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

Overview

Calculates the square distance between a single complex input for each point in a complex vector scaled by a scalar value.

Dispatcher Prototype

void volk_32fc_x2_s32f_square_dist_scalar_mult_32f(float* target, lv_32fc_t* src0,
lv_32fc_t* points, float scalar, unsigned int num_points)

Inputs

  • src0: The complex input. Only the first point is used.
  • points: A complex vector of reference points.
  • scalar: A float to scale the distances by
  • num_points: The number of data points.

Outputs

  • target: A vector of distances between src0 and the vector of points.

Example Calculate the distance between an input and reference points in a square 16-qam constellation. Normalize distances by the area of the constellation.

int N = 16;
unsigned int alignment = volk_get_alignment();
lv_32fc_t* constellation = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
lv_32fc_t* rx = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
float* out = (float*)volk_malloc(sizeof(float)*N, alignment);
float const_vals[] = {-3, -1, 1, 3};
unsigned int jj = 0;
for(unsigned int ii = 0; ii < N; ++ii){
constellation[ii] = lv_cmake(const_vals[ii%4], const_vals[jj]);
if((ii+1)%4 == 0) ++jj;
}
*rx = lv_cmake(0.5f, 2.f);
float scale = 1.f/64.f; // 1 / constellation area
volk_32fc_x2_s32f_square_dist_scalar_mult_32f(out, rx, constellation, scale, N);
printf("Distance from each constellation point:\n");
for(unsigned int ii = 0; ii < N; ++ii){
printf("%.4f ", out[ii]);
if((ii+1)%4 == 0) printf("\n");
}
volk_free(constellation);
volk_free(out);