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

Overview

Calculates the magnitude of the complexVector and stores the results in the magnitudeVector.

Dispatcher Prototype

void volk_32fc_magnitude_32f(float* 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.

Example Calculate the magnitude of $x^2 + x$ for points around the unit circle.

int N = 10;
unsigned int alignment = volk_get_alignment();
lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
float* magnitude = (float*)volk_malloc(sizeof(float)*N, alignment);
for(unsigned int ii = 0; ii < N/2; ++ii){
float real = 2.f * ((float)ii / (float)N) - 1.f;
float imag = std::sqrt(1.f - real * real);
in[ii] = lv_cmake(real, imag);
in[ii] = in[ii] * in[ii] + in[ii];
in[N-ii] = lv_cmake(real, imag);
in[N-ii] = in[N-ii] * in[N-ii] + in[N-ii];
}
volk_32fc_magnitude_32f(magnitude, in, N);
for(unsigned int ii = 0; ii < N; ++ii){
printf("out(%i) = %+.1f\n", ii, magnitude[ii]);
}
volk_free(magnitude);