GNU Radio Manual and C++ API Reference  3.7.7
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

Overview

Calculates the magnitude of the complexVector and stores the results in the magnitudeVector. The results are scaled and converted into 16-bit shorts.

Dispatcher Prototype

void volk_32fc_s32f_magnitude_16i(int16_t* magnitudeVector, const lv_32fc_t* complexVector, unsigned int num_points)

Inputs

  • complexVector: The complex input vector.
  • num_points: The number of samples.

Outputs

  • magnitudeVector: The output value as 16-bit shorts.

Example Generate points around the unit circle and map them to integers with magnitude 50 to preserve smallest deltas.

int N = 10;
unsigned int alignment = volk_get_alignment();
lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
int16_t* out = (int16_t*)volk_malloc(sizeof(int16_t)*N, alignment);
float scale = 50.f;
for(unsigned int ii = 0; ii < N/2; ++ii){
// Generate points around the unit circle
float real = -4.f * ((float)ii / (float)N) + 1.f;
float imag = std::sqrt(1.f - real * real);
in[ii] = lv_cmake(real, imag);
in[ii+N/2] = lv_cmake(-real, -imag);
}
volk_32fc_s32f_magnitude_16i(out, in, scale, N);
for(unsigned int ii = 0; ii < N; ++ii){
printf("out[%u] = %i\n", ii, out[ii]);
}
volk_free(out);