Vector Optimized Library of Kernels  3.0.0
Architecture-tuned implementations of math kernels

Overview

Calculates the square distance between a single complex input for each point in a complex vector.

Dispatcher Prototype

void volk_32fc_x2_square_dist_32f(float* target, lv_32fc_t* src0, lv_32fc_t* points,
unsigned int num_points) {
float complex lv_32fc_t
Definition: volk_complex.h:74

Inputs

  • src0: The complex input. Only the first point is used.
  • points: A complex vector of reference points.
  • 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.

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};
// Generate 16-QAM constellation points
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);
volk_32fc_x2_square_dist_32f(out, rx, constellation, 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);
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90
#define lv_cmake(r, i)
Definition: volk_complex.h:77
__VOLK_DECL_BEGIN VOLK_API void * volk_malloc(size_t size, size_t alignment)
Allocate size bytes of data aligned to alignment.
Definition: volk_malloc.c:38
VOLK_API void volk_free(void *aptr)
Free's memory allocated by volk_malloc.
Definition: volk_malloc.c:80