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

Overview

Computes the standard deviation and mean of the input buffer by means of Youngs and Cramer's Algorithm

Dispatcher Prototype

void volk_32f_stddev_and_mean_32f_x2(float* stddev, float* mean, const float*
inputBuffer, unsigned int num_points)

Inputs

  • inputBuffer: The buffer of points.
  • num_points The number of values in input buffer.

Outputs

  • stddev: The calculated standard deviation.
  • mean: The mean of the input buffer.

Example Generate random numbers with c++11's normal distribution and estimate the mean and standard deviation

int N = 1000;
unsigned int alignment = volk_get_alignment();
float* rand_numbers = (float*) volk_malloc(sizeof(float)*N, alignment);
float* mean = (float*) volk_malloc(sizeof(float), alignment);
float* stddev = (float*) volk_malloc(sizeof(float), alignment);
// Use a normal generator with 0 mean, stddev 1000
std::default_random_engine generator;
std::normal_distribution<float> distribution(0, 1000);
for(unsigned int ii = 0; ii < N; ++ii) {
rand_numbers[ii] = distribution(generator);
}
volk_32f_stddev_and_mean_32f_x2(stddev, mean, rand_numbers, N);
printf("std. dev. = %f\n", *stddev);
printf("mean = %f\n", *mean);
volk_free(rand_numbers);
volk_free(mean);
volk_free(stddev);
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90
__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