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

Overview

Rotate input vector at fixed rate per sample from initial phase offset.

Dispatcher Prototype

void volk_32fc_s32fc_x2_rotator_32fc(lv_32fc_t* outVector, const lv_32fc_t* inVector,
const lv_32fc_t phase_inc, lv_32fc_t* phase, unsigned int num_points)
float complex lv_32fc_t
Definition: volk_complex.h:74

Inputs

  • inVector: Vector to be rotated.
  • phase_inc: rotational velocity.
  • phase: initial phase offset.
  • num_points: The number of values in inVector to be rotated and stored into outVector.

Outputs

  • outVector: The vector where the results will be stored.

Example Generate a tone at f=0.3 (normalized frequency) and use the rotator with f=0.1 to shift the tone to f=0.4. Change this example to start with a DC tone (initialize in with lv_cmake(1, 0)) to observe rotator signal generation.

int N = 10;
unsigned int alignment = volk_get_alignment();
lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
lv_32fc_t* out = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
for(unsigned int ii = 0; ii < N; ++ii){
// Generate a tone at f=0.3
float real = std::cos(0.3f * (float)ii);
float imag = std::sin(0.3f * (float)ii);
in[ii] = lv_cmake(real, imag);
}
// The oscillator rotates at f=0.1
float frequency = 0.1f;
lv_32fc_t phase_increment = lv_cmake(std::cos(frequency), std::sin(frequency));
lv_32fc_t phase= lv_cmake(1.f, 0.0f); // start at 1 (0 rad phase)
// rotate so the output is a tone at f=0.4
volk_32fc_s32fc_x2_rotator_32fc(out, in, phase_increment, &phase, N);
// print results for inspection
for(unsigned int ii = 0; ii < N; ++ii){
printf("out[%u] = %+1.2f %+1.2fj\n",
ii, lv_creal(out[ii]), lv_cimag(out[ii]));
}
volk_free(out);
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90
#define lv_cimag(x)
Definition: volk_complex.h:98
#define lv_cmake(r, i)
Definition: volk_complex.h:77
#define lv_creal(x)
Definition: volk_complex.h:96
__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